open-cli-tools / concurrently

Run commands concurrently. Like `npm run watch-js & npm run watch-less` but better.
https://www.npmjs.com/package/concurrently
MIT License
7k stars 228 forks source link

Question: is there a simple way to run a single command with n concurrency? #426

Open jrnail23 opened 1 year ago

jrnail23 commented 1 year ago

I'm looking for a way to easily run the same command in parallel, specifying the number of concurrent executions. Does concurrently support that?

gustavohenke commented 1 year ago

Like --max-processes? 🙂

jrnail23 commented 1 year ago

But does that allow you to run one single command concurrently?

gustavohenke commented 1 year ago

No, I misunderstood your initial request.

So you're looking at a way to e.g. run echo "hello world" N times?

jrnail23 commented 1 year ago

@gustavohenke, yes, exactly

gustavohenke commented 1 year ago

There's nothing like that in the CLI currently, though there's some special syntax that could be built on, e.g. concurrently "npm:*(!fix) -- {@}" is valid. So you could have for example concurrently "echo Hello world{1:5}" or similar (I'm pretty sure some programming language has syntax like this, but I can't remember which 🤦).

Another option would be through the addition of a new flag, but I'm not sure how to make it ergonomic.

Finally, you can always do whatever you want programmatically:

import concurrently from 'concurrently';
concurrently(Array({ length: 5 }, (_, i) => `echo "Hello world${i}"`))

thoughts, @paescuj?