Skip to content
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): throws err when no args passed #862

Merged
merged 15 commits into from
Jun 1, 2019
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ For more information, see https://webpack.js.org/api/cli/.`);
try {
options = require("./utils/convert-argv")(argv);
} catch (err) {
// When webpack is not installed and no args passed to the CLI
pranshuchittora marked this conversation as resolved.
Show resolved Hide resolved
if (err.code === "MODULE_NOT_FOUND") {
let errorMessage =
"\n\u001b[31mwebpack not found, please install webpack using\n\t\u001b[33mnpm install --save-dev webpack\n";

if (process.env.npm_execpath !== undefined) {
EugeneHlushko marked this conversation as resolved.
Show resolved Hide resolved
if (process.env.npm_execpath.indexOf("yarn") !== -1) {
EugeneHlushko marked this conversation as resolved.
Show resolved Hide resolved
errorMessage =
"\n\u001b[31mwebpack not found, please install webpack using\n\t\u001b[33myarn add webpack --dev\n";
}
}

console.error(errorMessage);
return;
evenstensberg marked this conversation as resolved.
Show resolved Hide resolved
evenstensberg marked this conversation as resolved.
Show resolved Hide resolved
evenstensberg marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is fine, as long as we're doing it in the scope of only MODULE_NOT_FOUND

}

if (err.name !== "ValidationError") {
throw err;
}
Expand Down