UNPKG

807 BJavaScriptView Raw
1// #!/usr/bin/env node
2var nps = require('path')
3var child = require('child_process')
4var chalk = require('chalk')
5
6var over = require('../lib/lib/utils/overwrite-require')
7var _console = require('../lib/lib/utils/console').default
8var info = over.getInfo()
9
10
11function 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
18module.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}