rollup-plugin-execute icon indicating copy to clipboard operation
rollup-plugin-execute copied to clipboard

Pass JSON-serialized arguments to commands

Open GerkinDev opened this issue 7 years ago • 3 comments

Hi again,

It would be nice if, when calling the hook, arguments passed by rollup to the hook were transfered as arguments to the spawned process. This would allow to use positional parameters ($1, $2, $3..., $0 being obviously the shell) into the command, to eventually transfer it to other scripts.

It could be easily done by using the 2nd optional parameter of child_process.spawn here:

https://github.com/audinue/rollup-plugin-execute/blob/81476377f3c5ee88a9daf2bacbd6f41da3d10959/index.js#L20-L24

Again, I'm OK to submit a PR.

:beers: Cheers !

GerkinDev avatar Apr 06 '19 00:04 GerkinDev

Use case example please.

audinue avatar Apr 13 '19 06:04 audinue

For example, I'm using a script to execute actions on new file (in my case, refresh a manifest.json file). Using such parameters could help me avoid scanning the FS for new bundles.

For now, I have to use a naming convention to differenciate fresh rollup output files and already post-processed files. Using the writeBundle params ({ [fileName: string]: AssetInfo | ChunkInfo }), I could simply have a list of fresh files by parsing the $1 argument from JSON.

My use case relies on #3 too, and both of them together could allow to use this plugin in a pretty straightforward way to dispatch actions using rollup's data/intermediate state infos to other scripts, opening great possibilities in build processes.

GerkinDev avatar Apr 13 '19 09:04 GerkinDev

Hey there! What's up about this feature request ?

GerkinDev avatar Dec 13 '19 01:12 GerkinDev