emulate the `npm run-script` using stdio
npm install npm-run-scriptNpm Run Script
---
Installation
---
``bash`
npm install npm-run-script --save
Motivation
---
child_process doesn't know path of the local-installed npm commands.
`bash`
npm install eslint
node -e "require('child_process').exec('eslint').stderr.pipe(process.stderr)"/bin/sh: eslint: command not found
by using execa, this problem can be solved. but, can't inherit the stdout.
`bash`
npm install execa
node -e "require('execa').shell('eslint').then((result)=>console.log(result))"{ stdout: 'eslint [options] file.js [file.js] ...
npm-run-script inherits the stdio, and run the command and returns the [child_process.
`bash`
node -e "require('npm-run-script')('eslint').once('exit',(code)=>console.log('exit in',code))"eslint [options] file.js [file.js] [dir]
#Basic configuration:
...
exit in 0
API
---
-> childProcessrun the command as shell comand in childProcess.
`js
import npmRunScript from 'npm-run-script';
const command = 'eslint && exit 59';
const child = npmRunScript(command, { stdio: 'ignore' });// quiet...
child.once('error', (error) => {
console.trace(error);
process.exit(1);
});
child.once('exit', (exitCode) => {
console.trace('exit in', exitCode);
process.exit(exitCode);
});
`
Development
---
Requirement global
* NodeJS v5.10.0
* Npm v3.8.3
`bash
git clone https://github.com/59naga/npm-run-script
cd npm-run-script
npm install
npm test
``
License
---
MIT