UNPKG

806 BJavaScriptView Raw
1'use strict'
2
3const shelljs = require('shelljs')
4const exec = require('./exec')
5const PLUGIN_PATH = require('./path').PLUGIN_PATH
6const checkRegistry = require('./check').registry
7const config = require('./config')
8
9const 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
24exports.install = (name, registry) => npm(['install'].concat(name), registry)
25exports.update = (name, registry) => npm(['update'].concat(name), registry)
26exports.uninstall = name => npm(['uninstall'].concat(name))
27exports.list = () => npm(['list', '--depth=0'])