bcomnes / npm-run-all2

A CLI tool to run multiple npm-scripts in parallel or sequential. (Maintenance fork)
MIT License
262 stars 13 forks source link

Placeholder that unfolds into multiple tasks #134

Closed voxpelli closed 6 months ago

voxpelli commented 8 months ago

What is it?

This adds a new placeholder, {%}, which unfolds into multiple tasks – one for each input argument. The unfolded tasks gets assigned {1}, {2} etc instead of {%}.

Purpose

Be able to in parallell process a single npm task X times with a different argument each time.

Example

{
  "minimize-image": "some-cli-command",
  "build:image": "run-p 'minimize-image -- {%}' -- ./foo.png ./bar.png"
}

Same as:

run-p 'minimize-image -- ./foo.png' 'minimize-image -- ./bar.png'

Example using shell globbing

{
  "minimize-image": "some-cli-command",
  "build:image": "run-p 'minimize-image -- {%}' -- ./images/*.png"
}

Remains to move out of draft status:


Originally submitted at: https://github.com/mysticatea/npm-run-all/pull/180

bcomnes commented 8 months ago

Neat!

voxpelli commented 6 months ago

Any chance this will clobber existing commands people have set up?

Shouldn't be. If people are using custom placeholders and expecting them to pass through, then that would be an extreme edge case :)