UNPKG

edp-core

Version:

[![NPM version](https://img.shields.io/npm/v/edp-core.svg?style=flat-square)](https://npmjs.org/package/edp-core) [![Build Status](https://img.shields.io/travis/ecomfe/edp-core/master.svg?style=flat-square)](https://travis-ci.org/ecomfe/edp-core) [![Depen

36 lines (29 loc) 698 B
/** * @file 安装npm pkg的功能 * @author leeight(liyubei@baidu.com) */ var Deferred = require('./base/Deferred'); /** * 安装npm pkg * * @param {string|Array.<string>} pkgs 需要安装的npm pkg的名称. * @return {Deferred} */ exports.install = function (pkgs) { var d = new Deferred(); if (typeof pkgs === 'string') { pkgs = [pkgs]; } var args = ['install', '-g'].concat(pkgs); var npm = require('./util').spawn('npm', args, { stdio: 'inherit' }); npm.on('close', function (code) { if (code !== 0) { d.reject(new Error(code)); return; } d.resolve(); }); return d.promise; };