Coder Social home page Coder Social logo

open-cli-tools / concurrently Goto Github PK

View Code? Open in Web Editor NEW
6.8K 27.0 220.0 2.45 MB

Run commands concurrently. Like `npm run watch-js & npm run watch-less` but better.

Home Page: https://www.npmjs.com/package/concurrently

License: MIT License

JavaScript 5.82% TypeScript 94.13% Shell 0.04%
cli command-line concurrently parallel process spawn

concurrently's Introduction

concurrently

Latest Release License Weekly Downloads on NPM CI Status Coverage Status

Run multiple commands concurrently. Like npm run watch-js & npm run watch-less but better.

Demo

Table of Contents

Why

I like task automation with npm but the usual way to run multiple commands concurrently is npm run watch-js & npm run watch-css. That's fine but it's hard to keep on track of different outputs. Also if one process fails, others still keep running and you won't even notice the difference.

Another option would be to just run all commands in separate terminals. I got tired of opening terminals and made concurrently.

Features:

  • Cross platform (including Windows)
  • Output is easy to follow with prefixes
  • With --kill-others switch, all commands are killed if one dies
  • Spawns commands with spawn-command

Installation

concurrently can be installed in the global scope (if you'd like to have it available and use it on the whole system) or locally for a specific package (for example if you'd like to use it in the scripts section of your package):

npm Yarn pnpm Bun
Global npm i -g concurrently yarn global add concurrently pnpm add -g concurrently bun add -g concurrently
Local* npm i -D concurrently yarn add -D concurrently pnpm add -D concurrently bun add -d concurrently

* It's recommended to add concurrently to devDependencies as it's usually used for developing purposes. Please adjust the command if this doesn't apply in your case.

Usage

Note The concurrently command is now also available under the shorthand alias conc.

The tool is written in Node.js, but you can use it to run any commands.

Remember to surround separate commands with quotes:

concurrently "command1 arg" "command2 arg"

Otherwise concurrently would try to run 4 separate commands: command1, arg, command2, arg.

In package.json, escape quotes:

"start": "concurrently \"command1 arg\" \"command2 arg\""

NPM run commands can be shortened:

concurrently "npm:watch-js" "npm:watch-css" "npm:watch-node"

# Equivalent to:
concurrently -n watch-js,watch-css,watch-node "npm run watch-js" "npm run watch-css" "npm run watch-node"

NPM shortened commands also support wildcards. Given the following scripts in package.json:

{
  //...
  "scripts": {
    // ...
    "watch-js": "...",
    "watch-css": "...",
    "watch-node": "..."
    // ...
  }
  // ...
}
concurrently "npm:watch-*"

# Equivalent to:
concurrently -n js,css,node "npm run watch-js" "npm run watch-css" "npm run watch-node"

# Any name provided for the wildcard command will be used as a prefix to the wildcard
# part of the script name:
concurrently -n w: npm:watch-*

# Equivalent to:
concurrently -n w:js,w:css,w:node "npm run watch-js" "npm run watch-css" "npm run watch-node"

Exclusion is also supported. Given the following scripts in package.json:

{
  // ...
  "scripts": {
    "lint:js": "...",
    "lint:ts": "...",
    "lint:fix:js": "...",
    "lint:fix:ts": "..."
    // ...
  }
  // ...
}
# Running only lint:js and lint:ts
#   with lint:fix:js and lint:fix:ts excluded
concurrently "npm:lint:*(!fix)"

Good frontend one-liner example here.

Help:

concurrently [options] <command ...>

General
  -m, --max-processes          How many processes should run at once.
                               Exact number or a percent of CPUs available (for example "50%").
                               New processes only spawn after all restart tries
                               of a process.                            [string]
  -n, --names                  List of custom names to be used in prefix
                               template.
                               Example names: "main,browser,server"     [string]
      --name-separator         The character to split <names> on. Example usage:
                               -n "styles|scripts|server" --name-separator "|"
                                                                  [default: ","]
  -s, --success                Which command(s) must exit with code 0 in order
                               for concurrently exit with code 0 too. Options
                               are:
                               - "first" for the first command to exit;
                               - "last" for the last command to exit;
                               - "all" for all commands;
                               - "command-{name}"/"command-{index}" for the
                               commands with that name or index;
                               - "!command-{name}"/"!command-{index}" for all
                               commands but the ones with that name or index.
                                                                [default: "all"]
  -r, --raw                    Output only raw output of processes, disables
                               prettifying and concurrently coloring.  [boolean]
      --no-color               Disables colors from logging            [boolean]
      --hide                   Comma-separated list of processes to hide the
                               output.
                               The processes can be identified by their name or
                               index.                     [string] [default: ""]
  -g, --group                  Order the output as if the commands were run
                               sequentially.                           [boolean]
      --timings                Show timing information for all processes.
                                                      [boolean] [default: false]
  -P, --passthrough-arguments  Passthrough additional arguments to commands
                               (accessible via placeholders) instead of treating
                               them as commands.      [boolean] [default: false]

Prefix styling
  -p, --prefix            Prefix used in logging for each process.
                          Possible values: index, pid, time, command, name,
                          none, or a template. Example template: "{time}-{pid}"
                         [string] [default: index or name (when --names is set)]
  -c, --prefix-colors     Comma-separated list of chalk colors to use on
                          prefixes. If there are more commands than colors, the
                          last color will be repeated.
                          - Available modifiers: reset, bold, dim, italic,
                          underline, inverse, hidden, strikethrough
                          - Available colors: black, red, green, yellow, blue,
                          magenta, cyan, white, gray,
                          any hex values for colors (e.g. #23de43) or auto for
                          an automatically picked color
                          - Available background colors: bgBlack, bgRed,
                          bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite
                          See https://www.npmjs.com/package/chalk for more
                          information.               [string] [default: "reset"]
  -l, --prefix-length     Limit how many characters of the command is displayed
                          in prefix. The option can be used to shorten the
                          prefix when it is set to "command"
                                                          [number] [default: 10]
  -t, --timestamp-format  Specify the timestamp in moment/date-fns format.
                                   [string] [default: "yyyy-MM-dd HH:mm:ss.SSS"]

Input handling
  -i, --handle-input          Whether input should be forwarded to the child
                              processes. See examples for more information.
                                                                       [boolean]
      --default-input-target  Identifier for child process to which input on
                              stdin should be sent if not specified at start of
                              input.
                              Can be either the index or the name of the
                              process.                              [default: 0]

Killing other processes
  -k, --kill-others          Kill other processes if one exits or dies.[boolean]
      --kill-others-on-fail  Kill other processes if one exits with non zero
                             status code.                              [boolean]
      --kill-signal          Signal to send to other processes if one exits or dies.
                             (SIGTERM/SIGKILL, defaults to SIGTERM)    [string]

Restarting
      --restart-tries  How many times a process that died should restart.
                       Negative numbers will make the process restart forever.
                                                           [number] [default: 0]
      --restart-after  Delay time to respawn the process, in milliseconds.
                                                           [number] [default: 0]

Options:
  -h, --help         Show help                                         [boolean]
  -v, -V, --version  Show version number                               [boolean]


Examples:

 - Output nothing more than stdout+stderr of child processes

     $ concurrently --raw "npm run watch-less" "npm run watch-js"

 - Normal output but without colors e.g. when logging to file

     $ concurrently --no-color "grunt watch" "http-server" > log

 - Custom prefix

     $ concurrently --prefix "{time}-{pid}" "npm run watch" "http-server"

 - Custom names and colored prefixes

     $ concurrently --names "HTTP,WATCH" -c "bgBlue.bold,bgMagenta.bold"
     "http-server" "npm run watch"

 - Auto varying colored prefixes

     $ concurrently -c "auto" "npm run watch" "http-server"

 - Mixing auto and manual colored prefixes

     $ concurrently -c "red,auto" "npm run watch" "http-server" "echo hello"

 - Configuring via environment variables with CONCURRENTLY_ prefix

     $ CONCURRENTLY_RAW=true CONCURRENTLY_KILL_OTHERS=true concurrently "echo
     hello" "echo world"

 - Send input to default

     $ concurrently --handle-input "nodemon" "npm run watch-js"
     rs  # Sends rs command to nodemon process

 - Send input to specific child identified by index

     $ concurrently --handle-input "npm run watch-js" nodemon
     1:rs

 - Send input to specific child identified by name

     $ concurrently --handle-input -n js,srv "npm run watch-js" nodemon
     srv:rs

 - Shortened NPM run commands

     $ concurrently npm:watch-node npm:watch-js npm:watch-css

 - Shortened NPM run command with wildcard (make sure to wrap it in quotes!)

     $ concurrently "npm:watch-*"

 - Exclude patterns so that between "lint:js" and "lint:fix:js", only "lint:js"
 is ran

     $ concurrently "npm:*(!fix)"

 - Passthrough some additional arguments via '{<number>}' placeholder

     $ concurrently -P "echo {1}" -- foo

 - Passthrough all additional arguments via '{@}' placeholder

     $ concurrently -P "npm:dev-* -- {@}" -- --watch --noEmit

 - Passthrough all additional arguments combined via '{*}' placeholder

     $ concurrently -P "npm:dev-* -- {*}" -- --watch --noEmit

For more details, visit https://github.com/open-cli-tools/concurrently

API

concurrently can be used programmatically by using the API documented below:

concurrently(commands[, options])

  • commands: an array of either strings (containing the commands to run) or objects with the shape { command, name, prefixColor, env, cwd }.

  • options (optional): an object containing any of the below:

    • cwd: the working directory to be used by all commands. Can be overriden per command. Default: process.cwd().
    • defaultInputTarget: the default input target when reading from inputStream. Default: 0.
    • handleInput: when true, reads input from process.stdin.
    • inputStream: a Readable stream to read the input from. Should only be used in the rare instance you would like to stream anything other than process.stdin. Overrides handleInput.
    • pauseInputStreamOnFinish: by default, pauses the input stream (process.stdin when handleInput is enabled, or inputStream if provided) when all of the processes have finished. If you need to read from the input stream after concurrently has finished, set this to false. (#252).
    • killOthers: an array of exitting conditions that will cause a process to kill others. Can contain any of success or failure.
    • maxProcesses: how many processes should run at once.
    • outputStream: a Writable stream to write logs to. Default: process.stdout.
    • prefix: the prefix type to use when logging processes output. Possible values: index, pid, time, command, name, none, or a template (eg [{time} process: {pid}]). Default: the name of the process, or its index if no name is set.
    • prefixColors: a list of colors or a string as supported by chalk and additional style auto for an automatically picked color. If concurrently would run more commands than there are colors, the last color is repeated, unless if the last color value is auto which means following colors are automatically picked to vary. Prefix colors specified per-command take precedence over this list.
    • prefixLength: how many characters to show when prefixing with command. Default: 10
    • raw: whether raw mode should be used, meaning strictly process output will be logged, without any prefixes, coloring or extra stuff. Can be overriden per command.
    • successCondition: the condition to consider the run was successful. If first, only the first process to exit will make up the success of the run; if last, the last process that exits will determine whether the run succeeds. Anything else means all processes should exit successfully.
    • restartTries: how many attempts to restart a process that dies will be made. Default: 0.
    • restartDelay: how many milliseconds to wait between process restarts. Default: 0.
    • timestampFormat: a date-fns format to use when prefixing with time. Default: yyyy-MM-dd HH:mm:ss.ZZZ
    • additionalArguments: list of additional arguments passed that will get replaced in each command. If not defined, no argument replacing will happen.

Returns: an object in the shape { result, commands }.

  • result: a Promise that resolves if the run was successful (according to successCondition option), or rejects, containing an array of CloseEvent, in the order that the commands terminated.
  • commands: an array of all spawned Commands.

Example:

const concurrently = require('concurrently');
const { result } = concurrently(
  [
    'npm:watch-*',
    { command: 'nodemon', name: 'server' },
    { command: 'deploy', name: 'deploy', env: { PUBLIC_KEY: '...' } },
    {
      command: 'watch',
      name: 'watch',
      cwd: path.resolve(__dirname, 'scripts/watchers'),
    },
  ],
  {
    prefix: 'name',
    killOthers: ['failure', 'success'],
    restartTries: 3,
    cwd: path.resolve(__dirname, 'scripts'),
  },
);
result.then(success, failure);

Command

An object that contains all information about a spawned command, and ways to interact with it.
It has the following properties:

  • index: the index of the command among all commands spawned.
  • command: the command line of the command.
  • name: the name of the command; defaults to an empty string.
  • cwd: the current working directory of the command.
  • env: an object with all the environment variables that the command will be spawned with.
  • killed: whether the command has been killed.
  • state: the command's state. Can be one of
    • stopped: if the command was never started
    • started: if the command is currently running
    • errored: if the command failed spawning
    • exited: if the command is not running anymore, e.g. it received a close event
  • pid: the command's process ID.
  • stdin: a Writable stream to the command's stdin.
  • stdout: an RxJS observable to the command's stdout.
  • stderr: an RxJS observable to the command's stderr.
  • error: an RxJS observable to the command's error events (e.g. when it fails to spawn).
  • timer: an RxJS observable to the command's timing events (e.g. starting, stopping).
  • close: an RxJS observable to the command's close events. See CloseEvent for more information.
  • start(): starts the command, setting up all
  • kill([signal]): kills the command, optionally specifying a signal (e.g. SIGTERM, SIGKILL, etc).

CloseEvent

An object with information about a command's closing event.
It contains the following properties:

  • command: a stripped down version of Command, including only name, command, env and cwd properties.
  • index: the index of the command among all commands spawned.
  • killed: whether the command exited because it was killed.
  • exitCode: the exit code of the command's process, or the signal which it was killed with.
  • timings: an object in the shape { startDate, endDate, durationSeconds }.

FAQ

  • Process exited with code null?

    From Node child_process documentation, exit event:

    This event is emitted after the child process ends. If the process terminated normally, code is the final exit code of the process, otherwise null. If the process terminated due to receipt of a signal, signal is the string name of the signal, otherwise null.

    So null means the process didn't terminate normally. This will make concurrently to return non-zero exit code too.

  • Does this work with the npm-replacements yarn, pnpm, or Bun?

    Yes! In all examples above, you may replace "npm" with "yarn", "pnpm", or "bun".

concurrently's People

Contributors

aaronasachimp avatar abstractpoint avatar aecz avatar aidansteele avatar amilajack avatar baune8d avatar bengry avatar brandonchinn178 avatar cdrini avatar chbiel avatar coridyn avatar daniloraisi avatar daniloster avatar dependabot[bot] avatar detachhead avatar dwelle avatar eliasm307 avatar enaeseth avatar fauxfaux avatar gustavohenke avatar igrayson avatar jakeginnivan avatar kimmobrunfeldt avatar lynxtaa avatar msikma avatar naxoc avatar olsondev avatar paescuj avatar paulerickson avatar pgraham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

concurrently's Issues

Group or aggregate output?

If you use gnu parallel, it has one great feature of running tasks in parallel, but grouping all of the output for a each command and printing it when that command finishes. Is there a way to do this with concurrently? If not, it would be a great feature ๐Ÿ˜ƒ

Given these files

# script-one.sh
sleep 1
echo first
# script-two.sh
echo second
sleep 2
echo third

Using GNU parallel

$ parallel bash ::: script-one.sh script-two.sh
first
second
third

Using concurrently

$ concurrently "bash script-one.sh" "bash script-two.sh"
[1] second
[0] first
[0] bash script-one.sh exited with code 0
[1] third
[1] bash script-two.sh exited with code 0

Run npm scripts instead of commands

I think it would be useful if one could enable npm mode by adding --npm. This would take all commands passed to concurrently, and change it to npm run <command>. Additionally this could set the names to the npm script name. For example:

concurrently --names eslint,htmlhint,stylelint,karma,protractor,conventional-changelog-lint -p name 'npm run eslint' 'npm run htmlhint' 'npm run stylelint' 'npm run karma' 'npm run protractor' 'npm run conventional-changelog-lint'

could be rewritten as:

concurrently --npm eslint htmlhint stylelint karma protractor conventional-changelog-lint

Especially when used in package.json this would be much less cluttered. E.g.:

  "scripts": {
    "test": "concurrently --names eslint,htmlhint,stylelint,karma,protractor,conventional-changelog-lint -p name 'npm run eslint' 'npm run htmlhint' 'npm run stylelint' 'npm run karma' 'npm run protractor' 'npm run conventional-changelog-lint'",
    "conventional-changelog-lint": "conventional-changelog-lint --from HEAD~1",
    "eslint": "eslint --color .",
    "htmlhint": "htmlhint --config .htmlhintrc src/**/*.html",
    "karma": "karma start --colors --single-run karma-jenkins.conf.js",
    "protractor": "protractor",
    "stylelint": "stylelint ."
  },

would become:

  "scripts": {
    "test": "concurrently --npm eslint htmlhint stylelint karma protractor conventional-changelog-lint",
    "conventional-changelog-lint": "conventional-changelog-lint --from HEAD~1",
    "eslint": "eslint --color .",
    "htmlhint": "htmlhint --config .htmlhintrc src/**/*.html",
    "karma": "karma start --colors --single-run karma-jenkins.conf.js",
    "protractor": "protractor",
    "stylelint": "stylelint ."
  },

spawn-default-shell problem on 3.1.0

I'm getting Unable to detect platform shell type. Please set SHELL_EXECUTE_FLAG env variable. on Centos after upgrading to concurrently#3.1.0. The result of echo $SHELL is /bin/bash.

Maybe handle SIGINT?

I'm not sure (still sleepy :D) but maybe you should catch SIGINT and pass that through to the children, then e.g. wait for them to handle it and die. You could prompt the user to ^C another time if he wants to not wait and instead send SIGTERM to the children.

Concurrently 3.0.0 on Windows

I just updated to v 3.0.0 and now am receiving errors when using concurrently

Here is my output

$ npm start

> [email protected] start C:\dev\projects\proj
> concurrently --kill-others "npm run tsc:w" "npm run lite" "npm run styles:w"

[0] /c: /c: is a directory
[1] /c: /c: is a directory
[2] /c: /c: is a directory
[0] npm run tsc:w exited with code 126
[1] npm run lite exited with code 126   
[2] npm run styles:w exited with code 126

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.4.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `concurrently --kill-others "npm run tsc:w" "npm run lite" "npm run styles:w"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'concurrently --kill-others "npm run tsc:w" "npm run lite" "npm run styles:w"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the proj package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     concurrently --kill-others "npm run tsc:w" "npm run lite" "npm run styles:w"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs proj
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls proj
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\dev\projects\proj\npm-debug.log

And here is my scripts block in package.json

"scripts": {
    "start": "tsc && concurrently --kill-others \"npm run tsc:w\" \"npm run lite\" \"npm run styles:w\"",
    "lite": "lite-server",
    "postinstall": "jspm install && typings install",
    "jspm": "jspm",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings",
    "bundle:prod": "jspm bundle app --minify --inject",
    "bundle": "jspm bundle app --inject",
    "styles": "node-sass --output-style nested -o ./ scss/styles.scss --include-path node_modules",
    "styles:w": "npm run styles && node-sass scss -wo ./ --include-path node_modules"
  }

I think the problem I'm experiencing is related to this issue https://github.com/kimmobrunfeldt/chokidar-cli/issues/15

--kill-others not working properly

I am on windows 10 nodev 6.9.1

Something is wrong with the process termination. I have checked my exit codes, and tried a simple setInterval example, but the server process exits with code 0 when killed with ctrl+c (SIGINT) and exit code 1 from within concurrently.

here is the simplifier code to reproduce it

client.js

setTimeout(function(){process.exit(0);},2000);

server.js

    process.on('SIGTERM', function() {
        console.log('SIGTERM - Server closing...');
        process.exit(0);
    });
    process.on('SIGHUP', function() {
        console.log('SIGHUP - Server closing...');
        process.exit(0);
    });

    process.on('SIGINT', function() {
        console.log('SIGINT - Server closing...');
        process.exit(0);
    });
    process.on('exit', function() {
        console.log('EXIT - Server closing...');
        process.exit(0);
    });



    console.log('Server started, listening on port 4545');
    setInterval(function(){},1000);

image

One more weird thing, without --kill-others, the exit code on crtl+c is null
image

not reading command properly when used with npm?

You can see my issue from the log below. When run with npm, my concurrently script seems to be misinterpreting the commands. Both commands work fine manually. I am running on Windows 10. or have I just misinterpreted the docs?

npm run dev

> [email protected] dev C:\Users\George\Source\Repos\docs
> concurrently --kill-others 'tsc --watch' 'nodemon ./bin/www'

[0] 'ts' is not recognized as an internal or external command,
[0] operable program or batch file.
[1] '"./bin/www'"' is not recognized as an internal or external command,
[1] operable program or batch file.
[1] ./bin/www' exited with code 1
[0] ts exited with code 1

Is there a reason a pipe to process.stdout would not show as a log?

I have a server log handler that provides a reporter to send messages to the console. It uses a stream to pipe the log messages to process.stdout.

For some reason these never show up in the console outout of a process being run by concurrently. However, a simple call to console.log or console.info will work just fine.

Any ideas?

Minimum version?

Is there a minimum supported node version for this tool? If support was dropped node < v4, it would be possible to leverage some great ES6 features like template literals!

I think it's possible to enforce this through "engines" in package.json

Working directory

I need to start 2 commands in 2 distinct working directories. Is it possible with this tool ?

Spawn error on windows (cygwin)

Concurrently used to work fine for me on windows (cygwin), but since the version 3.0.0 it always triggers the same error:

 Error: spawn /bin/bash ENOENT
     at exports._errnoException (util.js:1036:11)
     at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
     at onErrorNT (internal/child_process.js:359:16)
     at _combinedTickCallback (internal/process/next_tick.js:74:11)
     at process._tickCallback (internal/process/next_tick.js:98:9)
     at Module.runMain (module.js:592:11)
     at run (bootstrap_node.js:394:7)
     at startup (bootstrap_node.js:149:9)
     at bootstrap_node.js:509:3

If you want to reproduce, you can simply use the angular 2 quickstart example and try to run it on this environment.

Add parameter/argument passthrough option

Running npm run dev -- --foo=bar will result in concurrently --raw "npm run start" "gulp watch" "--foo=bar" which doesn't properly add the parameter to any of the commands.

The double dash -- parameter passing is part of npm run so "you can use custom arguments when executing scripts", https://docs.npmjs.com/cli/run-script

{
  "scripts": {
    "dev": "concurrently --raw --parameter-passthrough \"npm run start\" \"gulp watch\""
  }
}

We could add an--parameter-passthrough option to concurrently that would add the last command chunk onto each command piece. The last chunk that would be considered parameters could even be separated by --.

So running npm run dev -- -- --foo=bar would result in the following after npm, concurrently --raw "npm run start" "gulp watch" "--" "--foo=bar" and then finally npm run start --foo=bar && gulp watch --foo=bar

An issue is adding the extra -- for npm run arg passing. As you can see above, for it to be effective, it would actually need to be npm run start -- --foo=bar && gulp watch --foo=bar. Perhaps the npm script should be updated to include the extra -- though: "dev": "concurrently --raw --parameter-passthrough \"npm run start --\" \"gulp watch\""


If we wanted to get fancier could even add separation with --0, --1 which would go to each indexed command chunk respectively, npm run dev -- --0 --foo=bar --1 --qux=dorf which would finally end up at npm run start -- --foo=bar && gulp watch --qux=dorf

Searching for maintainers with me

Hi,

concurrently has become a bit more popular nowadays and issues keep up piling. I would love to help with all issues but I don't have time to do everything.

If you are interested to join me maintaining and developing this tool, please raise your interest by commenting to this issue and shortly describing what you could help with.

PS. I'm currently on a vacation and will get back to maintaining this repo in a few weeks. Sorry for the delays, I know a lot of people are waiting for fixes.

Thanks everyone!

Extra newlines in output

You can probably guess which project this is from :) I did ./run-in-docker.sh in one terminal and concurrent --kill-others ./backend.sh ./frontend.sh in another.

2015-02-09 at 10 13

Concurrently 3.0.0 runs the wrong version of node

I use asdf to manage my node versions. The new shell execution method in concurrently 3 appears to ignore my asdf setup and my previous environment so it runs w/ an older, system node. This makes everything fail.

Allow piping

When I try to use the | pipe, I get weird errors. It seems concurrently considers the pipe to be an argument of the command.

$ concurrently --raw 'tail -f temp | grep foo'
tail -f temp | grep foo [ 'tail', '-f', 'temp', '|', 'grep', 'foo' ]
tail: |: No such file or directory
tail: grep: No such file or directory
tail: foo: No such file or directory

If I run the command without concurrently it works fine.

Colors not displaying with prefix enabled

I've noticed colors are only displayed by my webpack child process when using the --raw flag.

However, the --raw flag seems to disable prefixes.

Is it possible to have the child processes output their color and keep the prefixes I've assigned to them?

(Would love to have my cake and eat it! :D)

Error in forever

I want to use concurrent with forever. but that occur errors.

package.json

scripts: {
  "start": concurrent --kill-others \"npm run start-prod\" \"npm run start-prod-api\",
  ...
}
$ forever -c "npm run start" ./

UI?

Display output of separate processes in ncurses-like UI

Timestamp

Is it possible to have a timestamp before the console lines.

So something like this.

[2015-12-20 21:09:52] [1] Executing script: start-dev

Some child processes turn off color output

For example Typesafe Activator switches to monochrome output when running under concurrently. It'd be super nice if you could cheat & swindle it to output colors instead (unless of course concurrently's output was directed to a file). Dunno if this is possible or if child processes always know how their output stream works.

Request: restart process

Hey guys,

It would be nice if the concurrently could restart a process which died. This would allow in some cases, when you use build tasks or launch processes that could die but can be restored.

Propose

  • Add a --allow-restart flag to allow this behavior;
  • Add a --restart-after XXX flag to set a delay time to respawn the process;
  • Add a --restart-tries XXX flag to limit the number of respawn tries.

node in production with cucumber

hi man, i have some warnings in my console when i try run node in production with cucumber. What i wanna know is if there is some callback or promise for me run node in production first and then cucumber in second? or if have soma way to make something like setTimeout? Can U help me? Thank you.

Getting environment variable in arguments?

How can we handle environment variables from a concurrently command?

I need the full path of working directory in order to launch a Docker container. So, I need to use the $PWD environment variable.

With concurrently:

{
    "scripts": {
        "start": "concurrently 'echo ${PWD}'"
    }
}

It outputs ${PWD}. Yet, if I don't use concurrently:

{
    "scripts": {
        "start": "echo ${PWD}"
    }
}

It works. Any idea on how I can solve this? :)

Run the same command in multiple directories

I'm used to run the same command on multiple directories, and I'd like to switch to concurrently to take advantage of its nice output. How can achieve this?

Currently I'm doing this, without concurrently:

var child = require("child_process");
var directories = [ "foo", "bar", "baz" ];
directories.forEach(dir => child.spawn("ncu", [ "-a" ], { cwd: dir }));

Silent mode

Can you make a silent mode?

When using concurrently for build systems, its prompt gets a bit annoying.

Thanks.

Cancel concurrently tasks leave running processes even with `--kill-others`

Hey there,

when i run conccurrently and then cancel it with ctrl+c, there are running tasks.
Is there a concurrently cleanup or something like that?


My package.json:

{
  "name": "playground",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "build": "yarn run build:js && yarn run build:css",
    "build:css": "node-sass --source-map-embed --output-style compressed --recursive src/scss/style.scss > dist/css/combined.min.css",
    "build:js": "babel src/js/ --minified -o dist/js/combined.min.js",
    "dev:js": "babel src/js/ -o dist/js/combined.js",
    "dev:css": "node-sass --source-map-embed --output-style expanded --recursive src/scss/ --output dist/css/",
    "watch": "concurrently --kill-others \"yarn run dev:css -- --watch\" \"yarn run dev:js -- --watch\""
  },
  "dependencies": {
    "babel-cli": "^6.16.0",
    "babel-plugin-add-module-exports": "^0.2.1",
    "babel-plugin-transform-es2015-modules-umd": "^6.12.0",
    "babel-preset-es2015": "^6.16.0",
    "concurrently": "^3.1.0",
    "node-sass": "^3.10.1"
  }
}

running those tasks with npminstead of yarn results in the same issue.

It's sometimes useful to delay the start of one of the processes

I've needed this a couple of times when I've started a server in one of the processes, and some app that expects that server to be immediately available in the other process. I've been able to solve this problem by making use of the wait-on package, as follows:

"start": "concurrently -k -s first \"npm run server\" \"npm run app\"",
"server": "node server.js",
"app": "wait-on http://localhost:3000/ && node app.js"

I'm just creating this issue to help other people that hit the same issue.

not compatible with nodejs devtool

when debug using devtool, the output of concurrently is converted to plain string. I can't inspect the details inside an object using console.log. I tried to add option --raw. when doing this, all the output no longer redirects to the console of devtool

Extend Prefix with a Custom flag

Is it possible to prefix each command? So instead of the command saying npm run app or npm run api it would just be app or api.

Currently my command is like this.

"concurrently --timestamp-format 'YYYY-MM-DD HH:mm:ss' --prefix '[{time}] - [{index}]' --kill-others \"npm run start-dev:app\" \"npm run start-dev-api\""

With a result of this.

[2016-02-17 19:43:18] - [0] Connected to Database
[2016-02-17 19:43:18] - [1] Connected to API

Is it possible to do something like this?

"concurrently --timestamp-format 'YYYY-MM-DD HH:mm:ss' --prefix '[{time}] - [{custom}]' --custom 'APP,API' --kill-others \"npm run start-dev:app\" \"npm run start-dev-api\""

With a result of this.

[2016-02-17 19:43:18] - [API] Connected to Database
[2016-02-17 19:43:18] - [APP] Connected to API

sh: 1: concurrently: Permission denied

I'm using npm start command node version 5.9.0 in my ubuntu os of Linux 3.13.0-79-generic, but always got this error.
Error:

concurrently "npm run tsc:w" "npm run lite"
sh: 1: concurrently: Permission denied

bug

npm-debug.txt

Clean messy output

Example of messy output:

[1] ./node_modules/watchify/node_modules/through2/node_modules/xtend
[1] ./node_modules/watchify/no

... Lot of output of [0] process ...

[1] de_modules/through2/node_modules/xtend/.jshintrc

Outputs should be grouped so that lines wouldn't be cut.

Breaks when command contains `&&`?

If you clone https://github.com/airbnb/mocha-wrap and check out the concurrently branch, you'll see that npm run tests-only fails with, for example, "Error: cannot resolve path (or pattern) '&&'".

I would assume that concurrently 'foo' 'bar' would work for any foo or bar, even if it was multiple commands strung together serially.

The same tests work fine on the master branch with parallelshell.

Webpack progress output

When I run webpack with --progress you get a line that updates with the current progress, like this:

"dev": "webpack-dev-server -d --inline --progress"

webpack progress

But when I run the command through concurrently the output puts every progress update on a new line, causing tons of output:

"dev-watch": "concurrently --kill-others \"npm run dev\" \"npm run css-watch\""

concurrently progress

This happens on every small change so its pretty obnoxious. Is there a way to make the progress work as intended with concurrently?

Running two servers only outputs information from one of them.

I have a flask server backend for an express webpack-dev-server front-end and concurrently launching both works with source activate venv && concurrently "server serve -d" "npm start" (through an NPM script) as the front-end is correctly populating using the backend API points, BUT concurrently is only outputting the information from the express server to my terminal, and my flask backend hits aren't being displayed (i.e. all output is [1] ..., and there are no [0] ... logs). Is there a flag I'm missing, is this not possible, or is this a bug?


edit

Strange. It appears to be working correctly if I use the built-in flask app.run(...), but not with the gevent.pywsgi.WSGIServer(...) that the server is set up with...


edit May 31

Using --raw allows the flask server output to be displayed. Anyway to get this to work with the labels and colors?

Test code not testing src?

Hi there, I'm digging in trying to understand this code and thought I would try to understand the tests to start. I looked test/test-functional.js and found that it is testing a function run defined in test/utils.js.

I just want to make sure I'm not confused, but does that mean these tests aren't executing the source code at all? I feel like they should be

colors and --raw mode

I run 2 gulp scripts that stream logs in colors, but want to remove the [0] and [1] from output.

Problem is that when using --raw mode, colors are also removed from output.

I think it would make more sense to keep colors from underlying process, and allow to disable them only when using both --no-color option.

Custom prefix

Hey

Would it be possible to use a custom prefix? Instead of index I would like something like "client:index" so it shows up as client:0 or client:1 etc.

The reason for this is I start both my server and client with make which gives me two processes that are called 0 and two that are called 1. I would want to separate them a bit to make it more clear which process is doing what

Combination of lint + test coverage report throws

I see it pretty awkward. Same issue for parallelshell darkguy2008/parallelshell#36

21:06 $ `npm bin`/concurrent 'eslint .' 'node_modules/.bin/karma start ./karma.conf.js --single-run --reporters coverage' -w
[0] 
[0] fs.js:691
[0]   return binding.lstat(pathModule._makeLong(path));
[0]                  ^
[0] Error: ENOENT, no such file or directory '/Users/nkbt/nkbt/react-component-template/reports/coverage/prettify.js'
[0]     at Object.fs.lstatSync (fs.js:691:18)
[0]     at Object.realpathSync (fs.js:1279:21)
[0]     at executeOnFile (/Users/nkbt/.nvm/v0.10.40/lib/node_modules/eslint/lib/cli-engine.js:559:27)
[0]     at Array.forEach (native)
[0]     at /Users/nkbt/.nvm/v0.10.40/lib/node_modules/eslint/lib/cli-engine.js:626:49
[0]     at Array.forEach (native)
[0]     at CLIEngine.executeOnFiles (/Users/nkbt/.nvm/v0.10.40/lib/node_modules/eslint/lib/cli-engine.js:622:18)
[0]     at Object.cli.execute (/Users/nkbt/.nvm/v0.10.40/lib/node_modules/eslint/lib/cli.js:159:95)
[0]     at Object.<anonymous> (/Users/nkbt/.nvm/v0.10.40/lib/node_modules/eslint/bin/eslint.js:61:20)
[0]     at Module._compile (module.js:456:26)
[0] eslint . exited with code 8
[1] Hash: c026f8c83672b2f634d8
[1] Version: webpack 1.12.2
[1] Time: 5ms
[1] webpack: bundle is now VALID.
[1] webpack: bundle is now INVALID.
[1] Hash: 95583aaf2ae88eb15123
[1] Version: webpack 1.12.2
[1] Time: 1256ms
[1]         Asset    Size  Chunks             Chunk Names
[1] test/index.js  675 kB       0  [emitted]  test/index.js
[1] chunk    {0} test/index.js (test/index.js) 605 kB [rendered]
[1] webpack: bundle is now VALID.
[1] 27 09 2015 21:07:10.642:INFO [karma]: Karma v0.13.10 server started at http://localhost:9876/
[1] 27 09 2015 21:07:10.647:INFO [launcher]: Starting browser PhantomJS
[1] 27 09 2015 21:07:11.492:INFO [PhantomJS 1.9.8 (Mac OS X 0.0.0)]: Connected on socket N9E3oUbV-cfUo4UiAAAA with id 78409084
[1] ---------------|----------|----------|----------|----------|----------------|
[1] File           |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
[1] ---------------|----------|----------|----------|----------|----------------|
[1]  src/          |    88.89 |      100 |       50 |    66.67 |                |
[1]   Component.js |    88.89 |      100 |       50 |    66.67 |              6 |
[1] ---------------|----------|----------|----------|----------|----------------|
[1] All files      |    88.89 |      100 |       50 |    66.67 |                |
[1] ---------------|----------|----------|----------|----------|----------------|
[1] 
[1] node_modules/.bin/karma start ./karma.conf.js --single-run --reporters coverage exited with code 0

Node 0.10.40

3.3.0 fails to run commands on Windows 10

The problem was reproduced while trying out the quick-start Angular 2 app. With concurrently 2.2.0 everything runs fine.

Details:

$ concurrently --kill-others "npm run tsc:w" "npm run lite"
[1] /c: /c: is a directory
[0] /c: /c: is a directory
[0] npm run tsc:w exited with code 126
[1] npm run lite exited with code 126
$ npm -v
3.10.8
$ node -v
v6.7.0

nodemon + piped commands only works on first pass

I'm sorry I don't have a simpler repro case, but I wanted to report this.

With version 2, the following worked and all test runs with get parsed by tap-diff

  ./node_modules/.bin/concurrently \
    "command1" \
    "command2" \
    "./node_modules/.bin/nodemon -- ${@-} | ./node_modules/.bin/tap-diff" \
    --kill-others \
    --raw

With version 3, tap-diff will run on the first pass of nodemon, but not on subsequent runs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.