gruntjs / grunt-cli

Grunt's command line interface.
http://gruntjs.com/
MIT License
706 stars 248 forks source link

CLI options cwd and require are not parsed correctly in v1.3.0 #121

Closed stuikomma closed 6 years ago

stuikomma commented 6 years ago

When running grunt --require coffeescript/register I get the warning Warning: Task "coffeescript/register" not found. Use --force to continue.

https://github.com/gruntjs/grunt-cli/pull/117 introduced the cli options cwd and require. They are accessed here, but they are treated as boolean flags, because they are not passed as known arguments to nopt. This means that the arguments to cwd and require end up being interpreted as tasks names.

I think they should be added to the known object like this:

// Populate known object with args from grunt-known-options
// ...

// Add options that are unique to grunt-cli
known.cwd = {type: String};
known.require = {type: Array};

var options = nopt(known, aliases, process.argv, 2);
shama commented 6 years ago

Thanks for the report! I published a fix for require. A fresh npm install should grab that fix.

I mistakenly added the cwd option instead of using the existing base option. Please use base instead of cwd. Fix for that here: https://github.com/gruntjs/grunt-cli/pull/122

shama commented 6 years ago

Fixed with 1.3.1