Othernpm
Othernpm provides a way to run npm commands in other directories.
A typical use of this module would be to run npm scripts of subdirectories
that have own package.json
.
Usage
CLI
Othernpm allows you to specify a path where npm commands run.
# 'cd ./templates && npm install' % onpm ./templates install
You can also define paths in package.json
and use them to specify
a path.
# 'cd ./site && npm run build' % onpm site run build # 'cd ./examples && npm test' % onpm examples test
For example, this repository defines a npm-script named eg
in its package.json.
By this, we can run any npm command in test/example from the root directory like:
# Check defined npm-scripts in 'test/example'. % npm run eg -- run # Install Mocha as a dev-dependency of 'test/example'. % npm run eg -- install --save-dev mocha
Node.js API
Othernpm also provides API used in Node.js scripts.
The module loads configurations from package.json
automatically
so that you can use them as functions.
const onpm = ; // Run the 'start' script in the examples directory.onpm; // Run the 'build' script in the site directory.onpm; // Run npm commands in another directory.'test';
The othernpm function returns a spawn object.
const build = onpm;build;
Installation
npm install --save-dev othernpm
License
MIT