From 2250af02f639505938cafd4b28cd856aaf60d6d0 Mon Sep 17 00:00:00 2001 From: Pranshu Chittora Date: Fri, 26 Apr 2019 11:47:37 +0530 Subject: [PATCH] fix(cli): error when no webpack and args found trows an error when webpack is not installed and no args passed to the cli --- bin/cli.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index aa7df4c2d9c..54d28553174 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -71,7 +71,12 @@ For more information, see https://webpack.js.org/api/cli/.`); options = require("./utils/convert-argv")(argv); } catch (err) { if (err.name !== "ValidationError") { - throw err; + console.error("\n\u001b[1m\u001b[31mWebpack not found, please install webpack"); + console.error( + "\u001b[1m\u001b[31mAlternatively, run 'webpack(-cli) --help' for usage info.\u001b[39m\u001b[22m\n" + ); + process.exitCode = 1; + return; } const stack = ErrorHelpers.cleanUpWebpackOptions(err.stack, err.message); @@ -93,7 +98,7 @@ For more information, see https://webpack.js.org/api/cli/.`); */ const stdout = argv.silent ? { - write: () => {} + write: () => {} } // eslint-disable-line : process.stdout;