-
Notifications
You must be signed in to change notification settings - Fork 36
/
add.js
37 lines (34 loc) · 976 Bytes
/
add.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
const minimist = require('minimist');
const execSync = require('child_process').execSync;
const options = {
string: ['package', 'to', 'type'],
default: {
package: '',
to: '',
type: 'dep'
}
};
const argv = minimist(process.argv.slice(2), options);
if (argv.package !== '' && argv.to !== '') {
switch(argv.type) {
case 'dep':
execSync(`lerna add ${argv.package} --exact --scope="${argv.to}" --no-bootstrap && npm run bootstrap`, {
stdio: 'inherit'
});
break;
case 'dev':
execSync(`lerna add ${argv.package} --exact --scope="${argv.to}" --dev --no-bootstrap && npm run bootstrap`, {
stdio: 'inherit'
});
break;
case 'peer':
execSync(`lerna add ${argv.package} --exact --scope="${argv.to}" --peer --no-bootstrap && npm run bootstrap`, {
stdio: 'inherit'
});
break;
default:
console.error('Command error.');
}
} else {
console.error('Command error.');
}