Where can I get a handle for command line arguments?
eg grunt dist --env=UAT
. How do I get the value for env
?
While I'm at it, how would I assign a default value to this if it's not set on the command line?
Another way to share a parameter across multiple tasks would be to use grunt. option . In this example, running grunt deploy --target=staging on the command line would cause grunt. option('target') to return "staging".
Installing the CLI. Run sudo npm install -g grunt-cli (Windows users should omit "sudo ", and may need to run the command-line with elevated privileges). The grunt command-line interface comes with a series of options. Use grunt -h from your terminal to show these options.
So task runners like Grunt and Gulp still have their place and we still use both here at Delicious Brains as build tools for different products we develop.
You can use grunt.option()
or more specifically:
var env = grunt.option('env') || 'default';
to grab the env
argument or default to the string 'default'
if the argument is not present.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With