Skip to content

Commit

Permalink
fix: run CLI after webpack installation (#1951)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Oct 15, 2020
1 parent 92ad475 commit 564279e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions packages/webpack-cli/bin/cli.js
@@ -1,31 +1,39 @@
#!/usr/bin/env node

'use strict';

require('v8-compile-cache');

const importLocal = require('import-local');
const runCLI = require('../lib/bootstrap');
const { yellow } = require('colorette');
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;
}

0 comments on commit 564279e

Please sign in to comment.