From 564279e5b634a399647bcdb21449e5e6a7f0637e Mon Sep 17 00:00:00 2001 From: Alexander Akait Date: Thu, 15 Oct 2020 20:42:43 +0300 Subject: [PATCH] fix: run CLI after webpack installation (#1951) --- packages/webpack-cli/bin/cli.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/webpack-cli/bin/cli.js b/packages/webpack-cli/bin/cli.js index e591bb25dc5..9b7bb3392cd 100755 --- a/packages/webpack-cli/bin/cli.js +++ b/packages/webpack-cli/bin/cli.js @@ -1,7 +1,9 @@ #!/usr/bin/env node 'use strict'; + require('v8-compile-cache'); + const importLocal = require('import-local'); const runCLI = require('../lib/bootstrap'); const { yellow } = require('colorette'); @@ -9,23 +11,29 @@ const { error, success } = require('../lib/utils/logger'); const { packageExists } = require('../lib/utils/package-exists'); const { promptInstallation } = require('../lib/utils/prompt-installation'); -// Prefer the local installation of webpack-cli +// Prefer the local installation of `webpack-cli` if (importLocal(__filename)) { return; } + process.title = 'webpack'; +const [, , ...rawArgs] = process.argv; + if (packageExists('webpack')) { - const [, , ...rawArgs] = process.argv; runCLI(rawArgs); } else { - promptInstallation('webpack', () => { + promptInstallation('webpack -W', () => { error(`It looks like ${yellow('webpack')} is not installed.`); }) - .then(() => success(`${yellow('webpack')} was installed sucessfully.`)) + .then(() => { + success(`${yellow('webpack')} was installed sucessfully.`); + + runCLI(rawArgs); + }) .catch(() => { - process.exitCode = 2; error(`Action Interrupted, Please try once again or install ${yellow('webpack')} manually.`); + + process.exit(2); }); - return; }