diff --git a/bin/cli.js b/bin/cli.js index 105613a642b..630f387a912 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -496,6 +496,17 @@ For more information, see https://webpack.js.org/api/cli/.`); ); } else if (stats.hash !== lastHash) { lastHash = stats.hash; + if (stats.compilation && stats.compilation.errors.length !== 0) { + const errors = stats.compilation.errors; + if (errors[0].name === "EntryModuleNotFoundError") { + console.error( + "\n\u001b[1m\u001b[31mInsufficient number of arguments or no entry found." + ); + console.error( + "\u001b[1m\u001b[31mAlternatively, run 'webpack(-cli) --help' for usage info.\u001b[39m\u001b[22m\n" + ); + } + } const statsString = stats.toString(outputOptions); const delimiter = outputOptions.buildDelimiter ? `${outputOptions.buildDelimiter}\n` diff --git a/packages/utils/recursive-parser.test.js b/packages/utils/recursive-parser.test.js index 425a0a04817..9748cf4d07c 100644 --- a/packages/utils/recursive-parser.test.js +++ b/packages/utils/recursive-parser.test.js @@ -2,6 +2,7 @@ const defineTest = require("./defineTest"); + defineTest( __dirname, "init", diff --git a/test/binCases/no-options/development/stdin.js b/test/binCases/no-options/development/stdin.js index d1a888c24cb..0e25a9e56b4 100644 --- a/test/binCases/no-options/development/stdin.js +++ b/test/binCases/no-options/development/stdin.js @@ -1,13 +1,9 @@ "use strict"; module.exports = function testAssertions(code, stdout, stderr) { - expect(code).toBe(2); + expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[0]).toContain("Hash: "); - expect(stdout[1]).toContain("Version: "); - expect(stdout[2]).toContain("Time: "); - expect(stdout[4]).toContain(""); - expect(stdout[5]).toContain("ERROR in Entry module not found"); - expect(stdout[6]).toContain(""); + expect(stdout[3]).toContain("Insufficient number of arguments provided"); + expect(stdout[4]).toContain("Alternatively, run `webpack(-cli) --help` for usage info"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/no-options/none/stdin.js b/test/binCases/no-options/none/stdin.js index 791fb1a5277..0e25a9e56b4 100644 --- a/test/binCases/no-options/none/stdin.js +++ b/test/binCases/no-options/none/stdin.js @@ -1,16 +1,9 @@ "use strict"; module.exports = function testAssertions(code, stdout, stderr) { - expect(code).toBe(2); + expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[0]).toContain("Hash: "); - expect(stdout[1]).toContain("Version: "); - expect(stdout[2]).toContain("Time: "); - expect(stdout[4]).toContain(""); - expect(stdout[5]).toContain("WARNING"); - expect(stdout[6]).toContain("The \'mode\' option has not been set"); - expect(stdout[7]).toContain("You can also set it to \'none\'"); - expect(stdout[8]).toContain(""); - expect(stdout[9]).toContain("ERROR in Entry module not found"); + expect(stdout[3]).toContain("Insufficient number of arguments provided"); + expect(stdout[4]).toContain("Alternatively, run `webpack(-cli) --help` for usage info"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/no-options/production/stdin.js b/test/binCases/no-options/production/stdin.js index d1a888c24cb..0e25a9e56b4 100644 --- a/test/binCases/no-options/production/stdin.js +++ b/test/binCases/no-options/production/stdin.js @@ -1,13 +1,9 @@ "use strict"; module.exports = function testAssertions(code, stdout, stderr) { - expect(code).toBe(2); + expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[0]).toContain("Hash: "); - expect(stdout[1]).toContain("Version: "); - expect(stdout[2]).toContain("Time: "); - expect(stdout[4]).toContain(""); - expect(stdout[5]).toContain("ERROR in Entry module not found"); - expect(stdout[6]).toContain(""); + expect(stdout[3]).toContain("Insufficient number of arguments provided"); + expect(stdout[4]).toContain("Alternatively, run `webpack(-cli) --help` for usage info"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/no-options/stdin.js b/test/binCases/no-options/stdin.js new file mode 100644 index 00000000000..edf6842a583 --- /dev/null +++ b/test/binCases/no-options/stdin.js @@ -0,0 +1,5 @@ +"use strict"; + +module.exports = function testAssertions(code, stdout, stderr) { + expect(stdout[3]).toContain("Insufficient number of arguments provided"); +};