That is imho because grunt.option
works only for a grunt used flags, it doesnt take every shell argument you provide.
The esiest module-free solution is to parse your flag from process.argv
, that returns an array.
Your flags would start at position 2, so if --verbose
is the first argument, you would claim it by process.argv[2]
How do I pass command line arguments?
You can easily test it by creating a javascript file
var args = process.argv;
process.argv.forEach( (val, index, array) => {
var flag = val.replace(new RegExp('-', 'g'), '');
console.log(flag);
});
and calling it in your shell
node testParams.js --argument1 -t.
The outcome will look like this
hakim@cortana:~/Sites/DOODLINGS $ node testParams.js --verbose -t
/usr/local/Cellar/node/7.5.0/bin/node
/Users/hakim/Sites/DOODLINGS/testParams.js
verbose
t
With some googling, you can find module to extract params for you. I dont use grunt so cant help you much there.