Npm Run Script
Installation
npm install npm-run-script --save
Motivation
child_process
doesn't know path of the local-installed npm commands.
npm install eslintnode -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.
npm install execanode -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.
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
npmRunScript(command, spawnOptions={stdio:'inherit'})
-> childProcess
run the command
as shell comand in childProcess.
; const command = 'eslint && exit 59';const child = ;// quiet...child;child;
Development
Requirement global
- NodeJS v5.10.0
- Npm v3.8.3
git clone https://github.com/59naga/npm-run-scriptcd npm-run-scriptnpm install npm test