1 |
|
2 | var nps = require('path')
|
3 | var child = require('child_process')
|
4 | var chalk = require('chalk')
|
5 |
|
6 | var over = require('../lib/lib/utils/overwrite-require')
|
7 | var _console = require('../lib/lib/utils/console').default
|
8 | var info = over.getInfo()
|
9 |
|
10 |
|
11 | function install(pkg) {
|
12 | var cmd = 'npm install ' + pkg + ' --save-optional'
|
13 | console.log(' running: ', chalk.yellow.bold(cmd))
|
14 | var output = child.execSync(cmd, { cwd: info.path.rootPath })
|
15 | console.log(output.toString())
|
16 | }
|
17 |
|
18 | module.exports = function use(pkgs) {
|
19 | if (info.type === 'local') {
|
20 | console.log(
|
21 | chalk.read.bold(' ERROR: Picidae is in local position, you should run `npm install ' + pkgs.join(' ') + ' --save`!\n')
|
22 | )
|
23 | }
|
24 | else {
|
25 | pkgs.forEach(install)
|
26 | }
|
27 | process.exit()
|
28 | }
|