0.2.0 • Published 10 years ago
npm-cmd v0.2.0
npm-cmd
An API to execute npm commands programmatically.
Installation
npm install --save npm-cmdUsage
var npm = require('npm-cmd');
npm.install(['express', 'cookie-parser'], {save: true, cwd: '/tmp'}, function(err) {
if (err) {
console.log('Installation failed.');
} else {
console.log('Installation succeeded!');
}
});API
Methods
.install(pkgs, opts, done)
Run npm install where:
pkgsis an array of packages to install - optionaloptsis an object of key-value pairs - optionalopts.globalwhether npm should installopts.savewhether npm should save the packages to thedependencieskey inpackage.jsonopts.saveDevwhether npm should save the packages to thedevDependencieskey inpackage.jsonopts.registrythe registry which npm should source package information fromdoneis a function called when the command has finished - optional
.dedupe(pkgs, opts, done)
Run npm dedupe where:
pkgsis an array of packages to dedupe - optionaloptsis an object of key-value pairs - optionaldoneis a function called when the command has finished - optional
Options
Global options accepted by all commands:
opts.cwdis the directory where the command will be run