-
-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: run CLI after webpack installation (#1951)
- Loading branch information
1 parent
92ad475
commit 564279e
Showing
1 changed file
with
14 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |