mysticatea / npm-run-all

A CLI tool to run multiple npm-scripts in parallel or sequential.
MIT License
5.72k stars 240 forks source link

Placeholder to unfold single task into multiple tasks #180

Closed voxpelli closed 7 months ago

voxpelli commented 5 years 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"
}
voxpelli commented 5 years ago

Fixed linting errors, sorry for that.

Also, if you wonder why I chose {%} – no specific reason other than that it wasn't used before, didn't seem to have another meaning in eg. Bash + it was in line with the style of {@} and {*}

voxpelli commented 5 years ago

Now it's primarily failing because of .flat() only being supported in Node 11 and newer. That can of course be fixed if you like this PR @mysticatea

voxpelli commented 7 months ago

Moved to: https://github.com/bcomnes/npm-run-all2/pull/134