node concurrently模块 同时运行多个命令

同时运行多个命令。比如:

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

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值