1 | 'use strict'
|
2 |
|
3 | const shelljs = require('shelljs')
|
4 | const exec = require('./exec')
|
5 | const PLUGIN_PATH = require('./path').PLUGIN_PATH
|
6 | const checkRegistry = require('./check').registry
|
7 | const config = require('./config')
|
8 |
|
9 | const npm = (options, registry) => {
|
10 | registry = registry || config.get('registry')
|
11 |
|
12 | if (registry) {
|
13 | options.push(checkRegistry(registry))
|
14 | }
|
15 |
|
16 | const pwd = shelljs.pwd().stdout
|
17 |
|
18 | shelljs.cd(PLUGIN_PATH)
|
19 | options = options.concat(['--save', '--silent'])
|
20 | exec('npm', options, {stdio: 'inherit'})
|
21 | shelljs.cd(pwd)
|
22 | }
|
23 |
|
24 | exports.install = (name, registry) => npm(['install'].concat(name), registry)
|
25 | exports.update = (name, registry) => npm(['update'].concat(name), registry)
|
26 | exports.uninstall = name => npm(['uninstall'].concat(name))
|
27 | exports.list = () => npm(['list', '--depth=0'])
|