From 8d17b531a18439a85992d737d28bc83ff310a4ec Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 22 Feb 2018 21:16:38 +0100 Subject: [PATCH] Revert "Show help on no command" --- bin/webpack.js | 22 ++++--------------- .../help/help-output-no-command/stdin.js | 16 -------------- .../help/help-output-no-command/test.opts | 0 3 files changed, 4 insertions(+), 34 deletions(-) mode change 100644 => 100755 bin/webpack.js delete mode 100644 test/binCases/help/help-output-no-command/stdin.js delete mode 100644 test/binCases/help/help-output-no-command/test.opts diff --git a/bin/webpack.js b/bin/webpack.js old mode 100644 new mode 100755 index 1313de32688..65001101e13 --- a/bin/webpack.js +++ b/bin/webpack.js @@ -205,6 +205,7 @@ "Controls the output of lifecycle messaging e.g. Started watching files..." } }); + // yargs will terminate the process early when the user uses help or version. // This causes large help outputs to be cut short (https://github.com/nodejs/node/wiki/API-changes-between-v0.10-and-v4#process). // To prevent this we use the yargs.parse API and exit the process normally @@ -464,12 +465,9 @@ if (err) { lastHash = null; console.error(err.stack || err); - if (err.details) { - console.error(err.details); - } - process.exit(1); + if (err.details) console.error(err.details); + process.exit(1); // eslint-disable-line } - if (outputOptions.json) { stdout.write( JSON.stringify(stats.toJson(outputOptions), null, 2) + "\n" @@ -479,20 +477,10 @@ const statsString = stats.toString(outputOptions); if (statsString) stdout.write(statsString + "\n"); } - if (!options.watch && stats.hasErrors()) { process.exitCode = 2; - - const fs = require("fs"); - const context = stats.compilation.compiler.context; - const configPath = context + "/webpack.config.js"; - const configMissing = !fs.existsSync(configPath); - if (yargs.argv._.length === 0 && configMissing) { - yargs.showHelp("log"); - } } } - if (firstOptions.watch || options.watch) { const watchOptions = firstOptions.watchOptions || @@ -508,9 +496,7 @@ compiler.watch(watchOptions, compilerCallback); if (outputOptions.infoVerbosity !== "none") console.log("\nWebpack is watching the files…\n"); - } else { - compiler.run(compilerCallback); - } + } else compiler.run(compilerCallback); } processOptions(options); diff --git a/test/binCases/help/help-output-no-command/stdin.js b/test/binCases/help/help-output-no-command/stdin.js deleted file mode 100644 index 12056a98bda..00000000000 --- a/test/binCases/help/help-output-no-command/stdin.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -module.exports = function testAssertions(code, stdout, stderr) { - expect(code).toBe(2); - expect(stdout).toEqual(expect.anything()); - expect(stdout).toContain("Config options:"); - expect(stdout).toContain("Basic options:"); - expect(stdout).toContain("Module options:"); - expect(stdout).toContain("Output options:"); - expect(stdout).toContain("Advanced options:"); - expect(stdout).toContain("Resolving options:"); - expect(stdout).toContain("Optimizing options:"); - expect(stdout).toContain("Stats options:"); - expect(stdout).toContain("Options:"); - expect(stderr).toHaveLength(0); -}; diff --git a/test/binCases/help/help-output-no-command/test.opts b/test/binCases/help/help-output-no-command/test.opts deleted file mode 100644 index e69de29bb2d..00000000000