index | npm-run-all | run-s | run-p | Node API |
---|
A Node module to run given npm-scripts in parallel or sequential.
const runAll = require("npm-run-all");
runAll(["clean", "lint", "build:*"], {parallel: false})
.then(() => {
console.log("done!");
})
.catch(err => {
console.log("failed!");
});
runAll(["build:* -- --watch"], {parallel: true})
.then(() => {
console.log("done!");
})
.catch(err => {
console.log("failed!");
});
let promise = runAll(patterns, options);
Run npm-scripts.
string|string[]
-- Glob-like patterns for script names.object
boolean
--options.parallel
option.false
.string[]
--{1}
, {2}
). If pattern text has {1}
, it's replaced by options.arguments[0]
.boolean
--Promise
object will be rejected if one or more scripts threw error(s).false
.boolean
--false
.number
--options.parallel
option.Number.POSITIVE_INFINITY
.string
--process.env.npm_execpath
or "npm"
.object|null
--{"npm-run-all": {"test": 777, "test2": 333}}
null
.boolean
--false
.boolean
--false
.boolean
--options.parallel
option.false
.boolean
--silent
to the log level of npm.false
.stream.Readable|null
--process.stdin
in order to send from stdin.stream.Writable|null
--process.stdout
in order to print to stdout.stream.Writable|null
--process.stderr
in order to print to stderr.string[]|null
--null
, it reads from package.json
in the current directory.null
.runAll
returns a promise that will becomes fulfilled when all scripts are completed.
The promise will become rejected when any of the scripts exit with a non-zero code.
The promise gives results
to the fulfilled handler.results
is an array of objects which have 2 properties: name
and code
.
The name
property is the name of a npm-script.
The code
property is the exit code of the npm-script. If the npm-script was not executed, the code
property is undefined
.
runAll(["clean", "lint", "build"])
.then(results => {
console.log(`${results[0].name}: ${results[0].code}`); // clean: 0
console.log(`${results[1].name}: ${results[1].code}`); // lint: 0
console.log(`${results[2].name}: ${results[2].code}`); // build: 0
});
options.stdin
, options.stdout
, or options.stderr
in parallel mode, please configure max listeners by emitter.setMaxListeners(n) properly.process.stdXXX.isTTY
is false
, please configure max listeners of the process.stdXXX
properly. In that case, npm-run-all
uses piping to connect to child processes.process.stdXXX.isTTY
is true
, npm-run-all
uses inherit
option, so the configuration is unnecessary.