From 0c58580ca8cbd1ba386e30879396c2b860a158f3 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 9 Nov 2020 07:28:50 +0530 Subject: [PATCH] fix: use logger for error with proper exit code --- packages/webpack-cli/lib/utils/resolve-command.js | 1 + packages/webpack-cli/lib/utils/run-command.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/webpack-cli/lib/utils/resolve-command.js b/packages/webpack-cli/lib/utils/resolve-command.js index 7c39f7067a0..fc4d4e1d08e 100644 --- a/packages/webpack-cli/lib/utils/resolve-command.js +++ b/packages/webpack-cli/lib/utils/resolve-command.js @@ -17,6 +17,7 @@ const run = async (name, ...args) => { }); } catch (err) { logger.error(`Action Interrupted, use ${cyan('webpack-cli help')} to see possible commands.`); + process.exit(2); } } diff --git a/packages/webpack-cli/lib/utils/run-command.js b/packages/webpack-cli/lib/utils/run-command.js index 12e1bd1a4f5..bd5477c1ed1 100644 --- a/packages/webpack-cli/lib/utils/run-command.js +++ b/packages/webpack-cli/lib/utils/run-command.js @@ -1,4 +1,5 @@ const execa = require('execa'); +const logger = require('./logger'); async function runCommand(command, args = []) { try { @@ -7,7 +8,8 @@ async function runCommand(command, args = []) { shell: true, }); } catch (e) { - throw new Error(e); + logger.error(e); + process.exit(2); } }