-
-
Notifications
You must be signed in to change notification settings - Fork 621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cli): show help flag when defaults fail #466
Changes from 6 commits
2c9db31
4b50c34
3c6a631
0a89eb6
904e527
5c9fe7c
bac9c01
c604d3e
1bc3318
94579b7
26d7f8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
MIT License http://www.opensource.org/licenses/mit-license.php | ||
Author Tobias Koppers @sokra | ||
*/ | ||
const chalk = require("chalk"); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to trim here |
||
(function() { | ||
// wrap in IIFE to be able to use return | ||
|
@@ -496,6 +497,21 @@ 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") { | ||
stdout.write("\n" + chalk.red(errors[0].error.toString()) + "\n"); | ||
stdout.write( | ||
"\n" + chalk.blue("ERROR ") + "Insufficient number of arguments provided " + | ||
"\n" + chalk.blue("INFO ") + "Alternatively, run `webpack(-cli) --help` for usage info." + | ||
"\n\n" | ||
); | ||
process.exit(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should exit the process now as we've got no styling |
||
} | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for an else statement here |
||
const statsString = stats.toString(outputOptions); | ||
if (statsString) stdout.write(statsString + "\n"); | ||
} | ||
const statsString = stats.toString(outputOptions); | ||
const delimiter = outputOptions.buildDelimiter | ||
? `${outputOptions.buildDelimiter}\n` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict"; | ||
|
||
module.exports = function testAssertions(code, stdout, stderr) { | ||
expect(stdout[3]).toContain("Insufficient number of arguments provided"); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ module.exports = function testAssertions(stdout, stderr, done) { | |
expect(stdout).toEqual(expect.anything()); | ||
expect(stdout[0]).toContain(""); | ||
expect(stdout[1]).toContain("Webpack is watching the files…"); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for trim here |
||
expect(stderr).toHaveLength(0); | ||
done(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't have chalk here. Leave it unstyled for now