spawn-npm-install
Programmatically install/uninstall npm dependencies by spawning a npm
child process.
var install =
Returns the child process, so you can print install log/warnings like so:
var proc = procstderrprocstdout
Or, to preserve log output and colors:
PRs welcome.
Usage
spawn = require('spawn-npm-install')
proc = spawn.install(dependencies, [opt], [cb])
Spawns an npm install
using the given dependencies
(string or array of strings). You can pass opt
to the command, which will convert camel case to dash-case for the CLI arguments. The last parameter cb
is the callback which is passed (err)
on failure, or null otherwise.
You can specify a command
for options to use instead of the default npm
(e.g. for specialized analytics or other hooks).
Also accepts some options for the child process:
env
environment variablesstdio
the standard err/outcwd
the current working directory
Returns the child process.
Examples:
var install =
The default export spawn
is the same as spawn.install
, for symmetry.
proc = spawn.uninstall(dependencies, [opt], [cb])
The same as above, but triggers npm uninstall
instead.
License
MIT, see LICENSE.md for details.