Skip to content

Commit 0c57254

Browse files
committed
stop yargs from exiting process and to fix failing help-output test
closes webpack#5345
1 parent 008ac78 commit 0c57254

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

bin/config-yargs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var OPTIMIZE_GROUP = "Optimizing options:";
99
module.exports = function(yargs) {
1010
yargs
1111
.help("help")
12+
.exitProcess(false)
1213
.alias("help", "h")
1314
.version()
1415
.alias("version", "v")

bin/convert-argv.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ var interpret = require("interpret");
55
var prepareOptions = require("../lib/prepareOptions");
66

77
module.exports = function(yargs, argv, convertOptions) {
8+
if (argv["help"] === true || argv["version"] === true) {
9+
return {exitByHelpOrVersion: true};
10+
}
811

912
var options = [];
1013

bin/webpack.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,4 +370,12 @@ function processOptions(options) {
370370

371371
}
372372

373-
processOptions(options);
373+
// yargs will terminate the process early when the user uses help or version.
374+
// This causes large help outputs to be cut short (https://github.com/nodejs/node/wiki/API-changes-between-v0.10-and-v4#process).
375+
// To prevent this we configure yargs with .exitProcess(false).
376+
// However, we need to prevent processOptions and convert-argv from causing errorneous results,
377+
// so we only parse inputs if help or version was not called.
378+
if (!options.exitByHelpOrVersion) {
379+
processOptions(options);
380+
}
381+

0 commit comments

Comments
 (0)