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 7 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
23 changes: 16 additions & 7 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ 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 && process.env.npm_execpath.includes("yarn")) {
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 Expand Up @@ -326,19 +340,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