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 10 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
25 changes: 18 additions & 7 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, \u001b[33mplease install webpack using\n\t\u001b[32mnpm install --save-dev webpack\n";
Copy link
Member

Choose a reason for hiding this comment

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

webpack not installed, consider installing it using npm install --save-dev webpack

Copy link
Member

Choose a reason for hiding this comment

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

Indentation seems weird here, you don't need different color schemes for the not found part, the please install part and the installation text. Two colors is sufficient, one for the error stack and one for the npm save

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


if (process.env.npm_execpath !== undefined && process.env.npm_execpath.includes("yarn")) {
errorMessage =
"\n\u001b[31mwebpack not found, \u001b[33mplease install webpack using\n\t\u001b[32myarn add webpack --dev\n";
}

console.error(errorMessage);
Error.stackTraceLimit = 1;
process.exitCode = 1;
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 Expand Up @@ -326,19 +342,14 @@ For more information, see https://webpack.js.org/api/cli/.`);
const SIX_DAYS = 518400000;
const now = new Date();
if (now.getDay() === MONDAY) {
const {
access,
constants,
statSync,
utimesSync,
} = require("fs");
const { access, constants, statSync, utimesSync } = require("fs");
const lastPrint = statSync(openCollectivePath).atime;
const lastPrintTS = new Date(lastPrint).getTime();
const timeSinceLastPrint = now.getTime() - lastPrintTS;
if (timeSinceLastPrint > SIX_DAYS) {
require(openCollectivePath);
// On windows we need to manually update the atime
access(openCollectivePath, constants.W_OK, (e) => {
access(openCollectivePath, constants.W_OK, e => {
if (!e) utimesSync(openCollectivePath, now, now);
});
}
Expand Down