DEV Community

Discussion on: Handling Command-line Arguments in NPM Scripts

Collapse
 
mariopetrovic profile image
Mario Petrovic

This is great. Thanks for pointing to this npm feature.

I have a question, if i want to have argument that is purely a flag, how can i pass it to npm script. Example:

npm test --coverage
Enter fullscreen mode Exit fullscreen mode

I tried this and it didnt work:

"test": "react-scripts test --coverage=$npm_config_coverage"
Enter fullscreen mode Exit fullscreen mode

Is there a way to pass boolean type of flag to npm script?

NOTE:
I dont want to use -- delimiter to pass arguments as it is required for npm.

Collapse
 
peanutqaq profile image
PeanutQAQ

hi there. i have the same question. have you sovled this question? would you perfer to share me your solution?

Collapse
 
mariopetrovic profile image
Mario Petrovic

Hey. No luck on my side. I did not look anywhere else on this topic. This was mostly my curiosity rather than real life need.
If i stumble upon anything i will post it here.