-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
39 lines (33 loc) · 958 Bytes
/
index.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
38
39
const process = require('process');
const spawn = require('cross-spawn');
const minimist = require('minimist');
const pkg = require('./package.json');
function createNgxCli(args) {
const options = minimist(args, {
boolean: ['version'],
string: ['addons'],
alias: {v: 'version'}
});
if (options.version) {
return console.log(pkg.version);
}
const packages = ['-p', 'generator-ngx-rocket'];
const addons = options.addons ? options.addons.split(' ') : [];
addons.forEach((addon) => {
if (addon) {
packages.push('-p');
packages.push(
addon.startsWith('generator') || /[:/]/.test(addon)
? addon
: 'generator-' + addon
);
}
});
// Skip confirmation prompt
// eslint-disable-next-line camelcase
process.env.npm_config_yes = true;
return spawn.sync('npx', [...packages, 'ngx', 'new'].concat(args || []), {
stdio: 'inherit'
});
}
module.exports = createNgxCli;