Skip to content

Commit

Permalink
chore: update commander.js to v12 (#4315)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Nov 4, 2024
1 parent 9efd0d0 commit 8d9e5c0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/webpack-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@webpack-cli/info": "^2.0.2",
"@webpack-cli/serve": "^2.0.5",
"colorette": "^2.0.14",
"commander": "^10.0.1",
"commander": "^12.1.0",
"cross-spawn": "^7.0.3",
"envinfo": "^7.14.0",
"fastest-levenshtein": "^1.0.12",
Expand Down
3 changes: 2 additions & 1 deletion packages/webpack-cli/src/webpack-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,8 @@ class WebpackCLI implements IWebpackCLI {
process.exit(0);
};
this.program.helpOption(false);
this.program.addHelpCommand(false);
// Suppress the default help command
this.program.helpCommand(false);
this.program.option("-h, --help [verbose]", "Display help for commands and options.");

let isInternalActionCalled = false;
Expand Down
4 changes: 1 addition & 3 deletions test/api/CLI.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1703,11 +1703,9 @@ describe("CLI API", () => {
consoleSpy = jest.spyOn(global.console, "log");
exitSpy = jest.spyOn(process, "exit").mockImplementation(() => {});

cli.program.option("--color [value]", "any color", "blue");

await new Promise((resolve, reject) => {
try {
cli.run(["help", "--color"], { from: "user" });
cli.run(["help", "--mode"], { from: "user" });
resolve();
} catch (error) {
reject(error);
Expand Down
12 changes: 6 additions & 6 deletions test/api/__snapshots__/CLI.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
exports[`CLI API custom help output should display help information 1`] = `
[
[
"Usage: webpack --color [value]",
"Usage: webpack --mode <value>",
],
[
"Description: any color",
"Description: Enable production optimizations or development hints.",
],
[
"Default value: "blue"",
"Possible values: "development | production | none"",
],
[
"",
Expand All @@ -19,13 +19,13 @@ exports[`CLI API custom help output should display help information 1`] = `
",
],
[
"Webpack documentation: https://webpack.js.org/.",
"Webpack documentation: https://webpack.js.org/.",
],
[
"CLI documentation: https://webpack.js.org/api/cli/.",
"CLI documentation: https://webpack.js.org/api/cli/.",
],
[
"Made with ♥ by the webpack team.",
"Made with ♥ by the webpack team.",
],
]
`;
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4142,11 +4142,6 @@ combined-stream@^1.0.8:
dependencies:
delayed-stream "~1.0.0"

commander@^10.0.1:
version "10.0.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06"
integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==

commander@^12.1.0, commander@~12.1.0:
version "12.1.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3"
Expand Down

0 comments on commit 8d9e5c0

Please sign in to comment.