![]() We'll get Hello true true Kundel Dominik instead because it will interpret -last and -first as boolean flags and set their value to true and will pass the rest of the arguments to the script as unparsed arguments resulting in echo "Hello $npm_config_first $npm_config_last" "Kundel" "Dominik" being called.īut even with the argument parser being fairly strict, this is a super powerful tool if you are planning to create a few simple scripts and don't want to have to deal with the argument parsing. The first one way just passes the arguments directly to your actual command. There are two different ways you can pass arguments to npm scripts. However, sometimes you want to be able to pass arguments to your scripts so that they can be more dynamic. So far we covered how to create scripts, which environment variables are set and how to call the scripts. There's a variety of different useful variables in here and I encourage you to check it out, especially if you are working on creating automation scripts.Ĭheck out my blog post If you want to learn more about environment variables in Node.js in generalt.
0 Comments
Leave a Reply. |