Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
npm-run-all
Advanced tools
The npm-run-all package is a CLI tool to run multiple npm-scripts in parallel or sequential order. It is useful for orchestrating complex build processes and can be used to simplify scripts in the 'package.json' file of a Node.js project.
Run tasks sequentially
This command will run the 'clean' task first, then 'build:css', and finally 'build:js' in sequential order.
npm-run-all clean build:css build:js
Run tasks in parallel
This command will run all tasks that match the pattern 'watch:*' simultaneously.
npm-run-all --parallel watch:*
Run a mix of sequential and parallel tasks
This command will run the 'clean' task first, then all 'build:*' tasks in parallel, and finally all 'test:*' tasks in sequential order.
npm-run-all clean --parallel build:* --sequential test:*
Use with npm lifecycle events
This example shows how to use npm-run-all within the 'scripts' section of 'package.json' to run the 'serve' and 'watch' tasks in parallel when the 'start' script is invoked.
"scripts": { "start": "npm-run-all --parallel serve watch" }
Concurrently is similar to npm-run-all in that it can run multiple commands concurrently. It's a more general-purpose tool that can run arbitrary commands, not just npm scripts, and provides more options for output formatting.
Parallelshell is another alternative that can run multiple npm scripts in parallel. It is less feature-rich compared to npm-run-all and has been deprecated in favor of npm-run-all due to various issues.
run-p is a part of the npm-run-all package and can be used independently. It specifically focuses on running multiple npm scripts in parallel, similar to the '--parallel' option in npm-run-all.
run-s is also a part of the npm-run-all package and can be used on its own. It is designed to run multiple npm scripts sequentially, similar to the default behavior of npm-run-all without the '--parallel' flag.
A CLI tool to run multiple npm-scripts in parallel or sequential.
> npm-run-all clean lint build:*
npm install npm-run-all
0.10
(requires npm >= 2.0.0
, so please run npm install -g npm@latest
)0.12
4.x
5.x
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
.
Note: If a task exited with non zero code, the following tasks are not run.
npm-run-all --parallel watch:html watch:js
This is same as npm run watch:html & npm run watch:js
.
Of course, this works on Windows as well!
Note: If a task exited with non zero code, the other tasks and those descendant processes are killed with SIGTERM
(On Windows, with taskkill.exe /F /T
).
npm-run-all clean lint --parallel watch:html watch:js
clean
and lint
sequentially.watch:html
and watch:js
in parallell.npm-run-all a b --parallel c d --sequential e f --parallel g h i
a
and b
sequentially.c
and d
in parallell.e
and f
sequentially.g
, h
, and i
in parallell.npm-run-all "delay 3000" --parallel watch:*
npm-run-all --parallel "build:* -- --watch"
We can enclose a script name or a pattern in quotes to use arguments. When you use a pattern, arguments are forwarded to every matched task.
An example: https://gist.github.com/mysticatea/34949629c9e0a01a9e7d See also: https://docs.npmjs.com/cli/run-script
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 the actual npm-script list from package.json
in the current directory.
npm-run-all --parallel watch:**
If we use a globstar **
, runs both sub tasks and sub-sub tasks.
This matching rule is similar to glob.
The Difference is one -- the separator is :
, instead of /
.
var runAll = require("npm-run-all");
var promise = runAll(patterns, options);
Run npm-scripts.
string|string[]
-- Glob-like patterns for task names.object
boolean
--
A flag to run tasks in parallel.
Default is false
.stream.Readable|null
--
A readable stream to send to the stdin of npm-scripts.
Default is nothing.
Set process.stdin
in order to send from stdin.stream.Writable|null
--
A writable stream to receive from the stdout of npm-scripts.
Default is nothing.
Set process.stdout
in order to print to stdout.stream.Writable|null
--
A writable stream to receive from the stderr of npm-scripts
Default is nothing.
Set process.stderr
in order to print to stderr.string[]|null
--
A string array that is all task names.
By default, reads from package.json
in the current directory.object|null
--
A map-like object to overwrite package configs.
Keys are package names.
Every value is a map-like object (Pairs of variable name and value).
e.g. {"npm-run-all": {"test": 777, "test2": 333}}
Default is null
.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.
See also: https://doc.esdoc.org/github.com/mysticatea/npm-run-all/
FAQs
A CLI tool to run multiple npm-scripts in parallel or sequential.
The npm package npm-run-all receives a total of 2,610,503 weekly downloads. As such, npm-run-all popularity was classified as popular.
We found that npm-run-all demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.