1 | # Concurrently
|
2 |
|
3 | [![Build Status](https://travis-ci.org/kimmobrunfeldt/concurrently.svg)](https://travis-ci.org/kimmobrunfeldt/concurrently)
|
4 |
|
5 | **Version: 0.1.1** ([*previous stable*](https://github.com/kimmobrunfeldt/concurrently/tree/0.1.0))
|
6 |
|
7 | Run multiple commands concurrently.
|
8 | Like `npm run watch-js & npm run watch-less` but better.
|
9 |
|
10 | ![](docs/demo.gif)
|
11 |
|
12 | It also works on Windows. You can tune your npm scripts to work across platforms.
|
13 |
|
14 | ## Install
|
15 |
|
16 | The tool is written in Node.js, but you can use it to run **any** commands.
|
17 |
|
18 | ```bash
|
19 | npm install -g concurrently
|
20 | ```
|
21 |
|
22 | ## Usage
|
23 |
|
24 | Remember to surround separate commands with quotes, like this:
|
25 | ```bash
|
26 | concurrent "command1 arg" "command2 arg"
|
27 | ```
|
28 |
|
29 | Otherwise **concurrent** would try to run 4 separate commands:
|
30 | `command1`, `arg`, `command2`, `arg`.
|
31 |
|
32 | Help:
|
33 |
|
34 | ```
|
35 | Usage: concurrent [options] <command ...>
|
36 |
|
37 | Options:
|
38 |
|
39 | -h, --help output usage information
|
40 | -V, --version output the version number
|
41 | -k, --kill-others kill other processes if one exits or dies
|
42 | --no-color disable colors from logging
|
43 | -p, --prefix <prefix> prefix used in logging for each process.
|
44 | Possible values: index, pid, command, none. Default: index
|
45 |
|
46 | -r, --raw output only raw output of processes, disables prettifying and colors
|
47 | -l, --prefix-length <length> limit how many characters of the command is displayed in prefix.
|
48 | The option can be used to shorten long commands.
|
49 | Works only if prefix is set to "command". Default: 10
|
50 |
|
51 |
|
52 | Examples:
|
53 |
|
54 | - Kill other processes if one exits or dies
|
55 |
|
56 | $ concurrent --kill-others "grunt watch" "http-server"
|
57 |
|
58 | - Output nothing more than stdout+stderr of child processes
|
59 |
|
60 | $ concurrent --raw "npm run watch-less" "npm run watch-js"
|
61 |
|
62 | - Normal output but without colors e.g. when logging to file
|
63 |
|
64 | $ concurrent --no-color "grunt watch" "http-server" > log
|
65 |
|
66 | For more details, visit https://github.com/kimmobrunfeldt/concurrently
|
67 | ```
|
68 |
|
69 | ## FAQ
|
70 |
|
71 | * Process exited with code *null*?
|
72 |
|
73 | From [Node child_process documentation](http://nodejs.org/api/child_process.html#child_process_event_exit), `exit` event:
|
74 |
|
75 | > This event is emitted after the child process ends. If the process
|
76 | > terminated normally, code is the final exit code of the process,
|
77 | > otherwise null. If the process terminated due to receipt of a signal,
|
78 | > signal is the string name of the signal, otherwise null.
|
79 |
|
80 |
|
81 | So *null* means the process didn't terminate normally. This will make **concurrent**
|
82 | to return non-zero exit code too.
|
83 |
|
84 |
|
85 | ## Why
|
86 |
|
87 | I like [task automation with npm](http://substack.net/task_automation_with_npm_run)
|
88 | but the usual way to run multiple commands concurrently is
|
89 | ```npm run watch-js & npm run watch-css```. That's fine but it's hard to keep
|
90 | on track of different outputs. Also if one process fails, others still keep running
|
91 | and you won't even notice the difference.
|
92 |
|
93 | Another option would be to just run all commands in separate terminals. I got
|
94 | tired of opening terminals and made **concurrently**.
|
95 |
|
96 | ### NPM Issue
|
97 |
|
98 | Previously I thought this could fix some problems I had with watching scripts and this readme said:
|
99 |
|
100 | > When running watch or serve tasks, I'd recommend to use `--kill-others` option:
|
101 | >
|
102 | > ```bash
|
103 | > concurrent --kill-others "npm run watch-js" "npm run watch-less"
|
104 | > ```
|
105 | >
|
106 | > That way, if for some reason e.g. your `watch-less` died, you would notice it easier.
|
107 |
|
108 | However NPM didn't work as I hoped it would. See [this issue](https://github.com/kimmobrunfeldt/concurrently/issues/4).
|
109 |
|
\ | No newline at end of file |