Reputation: 12649
Say I have the following npm script:
"test": "node $FILE"
How would I pass an absolute path to it via cli?
Example:
FILE="pwd + filename" npm run test
which should result in:
node /Root/Subfolder/filename
I'm on MacOS using NodeJS 14.
Upvotes: 0
Views: 306
Reputation: 14627
For example, you have a script file e.g. ./scripts/test.js
.
The script config would be like this:
"test": "node ${FILE}"
And, the command to run it would be:
$ FILE="$(pwd)/scripts/test.js" npm run test
Upvotes: 1