同时运行多个命令。比如:
npm run watch-js & npm run watch-less
但比这种方式要更好一些。
它也适用于Windows。你可以调整npm脚本达到跨平台运行的效果。
安装
这个工具是使用nodejs写的,但是可以用来运行任何命令
你可以选择全局安装
npm install -g concurrently
也可以局部安装
npm install concurrently --save-dev
用法
请记住用引号将每个单独的命令括起来,如下所示:
concurrent "command1 arg" "command2 arg"
否则,concurrent将尝试运行4个单独的命令:
command1, arg, command2, arg
在双引号内需要转义
"concurrently \"npm run dev:preload\" \"npm run dev:electron\""
示例
Help
Usage: concurrent [options] <command ...>
Options:
-h, --help output usage information
-V, --version output the version number
-k, --kill-others kill other processes if one exits or dies
--no-color disable colors from logging
-p, --prefix <prefix> prefix used in logging for each process.
Possible values: index, pid, command, none. Default: index
-r, --raw output only raw output of processes, disables prettifying and colors
-l, --prefix-length <length> limit how many characters of the command is displayed in prefix.
The option can be used to shorten long commands.
Works only if prefix is set to "command". Default: 10
Examples:
- Kill other processes if one exits or dies
$ concurrent --kill-others "grunt watch" "http-server"
- Output nothing more than stdout+stderr of child processes
$ concurrent --raw "npm run watch-less" "npm run watch-js"
- Normal output but without colors e.g. when logging to file
$ concurrent --no-color "grunt watch" "http-server" > log
For more details, visit https://github.com/kimmobrunfeldt/concurrently
npm 地址:https://www.npmjs.com/package/concurrently/v/1.0.0