Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gruntjs - command line arguments

Tags:

gruntjs

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?

like image 910
Roy Truelove Avatar asked Nov 12 '12 21:11

Roy Truelove


People also ask

How do I pass a parameter to a grunt task?

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".

How do I download grunt from command line?

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.

Is grunt still used?

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.


1 Answers

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.

like image 193
Kyle Robinson Young Avatar answered Sep 22 '22 00:09

Kyle Robinson Young