/
cli.js
executable file
·37 lines (29 loc) · 1015 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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`
if (importLocal(__filename)) {
return;
}
process.title = 'webpack';
if (packageExists('webpack')) {
runCLI(process.argv);
} else {
promptInstallation('webpack', () => {
error(`It looks like ${yellow('webpack')} is not installed.`);
})
.then(() => {
success(`${yellow('webpack')} was installed successfully.`);
runCLI(process.argv);
})
.catch(() => {
error(`Action Interrupted, Please try once again or install ${yellow('webpack')} manually.`);
process.exit(2);
});
}