Is there a way to pass command line arguments to an npm 'pre' script or to a script which runs multiple commands?
Assuming a simple script mySexyScript.js
that just logs out the process.argv :
console.log(process.argv);
This works
With an npm script:
...
"scripts": {
....
"sexyscript": "node mySexyScript.js"
....
}
...
running:
npm run sexyscript -- --foo=bar
the arguments are logged to the console as expected.
'pre' script - This doesn't work
With an npm script:
...
"scripts": {
....
"presexyscript": "node mySexyScript.js"
"sexyscript": "node mySuperSexyScript.js"
....
}
...
running:
npm run sexyscript -- --foo=bar
the arguments are not passed to mySexyScript and they are not logged
Multiple commands - This also doesn't work
With an npm script:
...
"scripts": {
....
"sexyscript": "node mySexyScript.js && node mySuperSexyScript.js"
....
}
...
running:
npm run sexyscript -- --foo=bar
the arguments are not passed to mySexyScript and they are not logged