You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 11, 2022. It is now read-only.
At the moment, there's really no way to pass arguments to scripts specified in the "scripts" field with npm run-script.
I have three options, currently:
Hard-code the flags into the "scripts" field. This obviously doesn't cover all situations; there's plenty of situations where I want to vary options I pass to some of the scripts, or make the scripts I write more widely applicable / configurable.
Pack the flags into an environment variable. This isn't very composable, it's quite un-UNIX-y, and it requires me to define all of the flags in one place. (Not to mention that WITH="--debug --optimize" npm run-scripts compile just ain't very pretty. ;)
Wrap the script in question (if it's not my own), and query the user interactively. Again, not remotely composable or UNIX-y; and to boot, means I have to interact with the script every single time I run it.
Here's my suggestion:
-fLGs and --flags that come after the second extant argument to run-script are appended to the string in the "scripts" field before it's run
anything after -- is appended to the string in the "scripts" field, before it's run
Examples:
npm run-scripts test -- something/something_else.js
This is completely backwards-compatible with what exists now; it does mean that we'd have to explicitly name the current module if we didn't use --, but that's minor, when it guarantees backwards compatibility.
k0pernikus, stevenvachon, jmwilkinson, Noor0, Delysid and 2 more