A CLI tool to run multiple npm-scripts sequentially or in parallel.
This package works in both Windows and UNIX-like environments.
It requires at least node version 0.10 and npm version 2.0.0. To upgrade npm, run:
npm install -g npm@latest
npm install npm-run-all
Usage: npm-run-all [OPTIONS] [...tasks]
Run specified tasks.
Options:
-h, --help Print this text.
-p, --parallel [...tasks] Run a group of tasks in parallel.
-s, --sequential [...tasks] Run a group of tasks sequentially.
-v, --version Print version number.
npm-run-all build:html build:js
This is same as npm run build:html && npm run build:js
.
npm-run-all --parallel watch:html watch:js
This is same as npm run watch:html & npm run watch:js
.
Of course, this can be run on Windows as well!
npm-run-all clean lint --parallel watch:html watch:js
- First, this runs
clean
andlint
sequentially. - Next, runs
watch:html
andwatch:js
in parallell.
npm-run-all a b --parallel c d --sequential e f --parallel g h i
- First, runs
a
andb
sequentially. - Second, runs
c
andd
in parallell. - Third, runs
e
andf
sequentially. - Lastly, runs
g
,h
, andi
in parallell.
npm-run-all --parallel watch:*
In this case, runs sub tasks of watch
. e.g. watch:html
, watch:js
.
But, doesn't run sub-sub tasks. e.g. watch:js:index
.
npm-run-all
reads a task list frompackage.json
at the current working directory.
npm-run-all --parallel watch:**:*
If you use a globstar **
, runs both sub tasks and sub-sub tasks.
This matching rule is similar to glob.
Its difference is one; the separator is :
, instead of /
.
var runAll = require("npm-run-all");
var promise = runAll(tasks, options);
Run npm-scripts.
- tasks
string|string[]
-- Glob-like patterns for task names. - options
object
- options.parallel
boolean
-- A flag to run tasks in parallel. By default,false
. - options.stdin
stream.Readable
-- A readable stream that sends to stdin of tasks. By default, nothing. Setprocess.stdin
in order to send from key inputs. - options.stdout
stream.Writable
-- A writable stream that receives stdout of tasks. By default, nothing. Setprocess.stdout
in order to print to console. - options.stderr
stream.Writable
-- A writable stream that receives stderr of tasks. By default, nothing. Setprocess.stderr
in order to print to console. - options.taskList
string[]
-- A string array that is all task names. By default, reads frompackage.json
at the current working directory.
- options.parallel
runAll
returns a promise that becomes fulfilled when all tasks are completed.
The promise will become rejected when any of the tasks exit with a non-zero code.