Skip to content

Commit

Permalink
chore: improved err msg
Browse files Browse the repository at this point in the history
  • Loading branch information
evenstensberg committed Jun 11, 2019
1 parent a2062f2 commit 23eddcb
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,17 @@ For more information, see https://webpack.js.org/api/cli/.`);
let errorMessage = "";

if (moduleName === "webpack") {
errorMessage = `\n\u001b[31m${moduleName} not installed`;
instructions = `Consider installing it using " npm install --save-dev ${moduleName} "\n`;
errorMessage = `\n${moduleName} not installed`;
instructions = `Install webpack to start bundling: \u001b[32m\n $ npm install --save-dev ${moduleName}\n`;

if (process.env.npm_execpath !== undefined && process.env.npm_execpath.includes("yarn")) {
instructions = `Consider installing it using " yarn add ${moduleName} --dev "\n`;
instructions = `Install webpack to start bundling: \u001b[32m\n $ yarn add ${moduleName} --dev\n`;
}
} else {
errorMessage = `\n\u001b[31mModule ${moduleName} is not found but is imported in configuration`;
instructions = `If ${moduleName} is a package, install it using a package manager\n`;
Error.stackTraceLimit = 1;
console.error(`${errorMessage}\n\n${instructions}`);
process.exitCode = 1;
return;
}

console.error(`${errorMessage}\n\n\u001b[32mTIP: ${instructions}`);
Error.stackTraceLimit = 1;
process.exitCode = 1;
return;
}

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

0 comments on commit 23eddcb

Please sign in to comment.