gruntjs / grunt-cli

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

--base and --gruntfile joint usage is unexpected #112

Open timolehto opened 7 years ago

timolehto commented 7 years ago

When this fix https://github.com/gruntjs/grunt-cli/commit/db61cee4f153b2cfdd90b1034e3ef22b073db433 was merged for back in the days for v0.1.12, things worked nice and clear. --base specified the base dir --gruntfile specified the gruntfile, and if no base was given base was inferred from gruntfile, just as if you hadn't specified it at all

Then two days later came 0.1.13 with https://github.com/gruntjs/grunt-cli/commit/c60e4192abeec26361ca4bae1f94ce630b53b063 and ruined it --base specifies the base dir only if no gruntfile specified, otherwise it's silently ignored --gruntfile specifies the base dir and gruntfile

I find this decision to opt out of the IMHO much more logical 0.1.12 logic very strange and in clear violation of POLA. Perhaps there's a valid reason, but I just can't see it. I would personally like to see this reverted.

However, at the very least I think this should definitely be more clearly communicated. It should warn (or even error?) if the extraneous --base option is provided when --gruntfile is specified and this should definitely be communicated in the --help docs more clearly, (which) currently say:

                            --base  Specify an alternate base path. By default,
                                    all file paths are relative to the         
                                    Gruntfile. (grunt.file.setBase) *          
                       --gruntfile  Specify an alternate Gruntfile. By default,
                                    grunt looks in the current or parent       
                                    directories for the nearest Gruntfile.js or
                                    Gruntfile.coffee file.      

Which leads one to believe Gruntfile is default and base can override. In light of the docs the current behaviour is quite strange.

We actually have some old deployment scripts/tools that have been built to rely on the capability to provide Gruntfile and base dir separately and this means we are locked to using grunt-cli 0.1.12. It is quite a coincident that the person who wrote the damn thing happened to have that particular grunt-cli version installed, but so it appears to be. :)

timolehto commented 7 years ago

Or if this can't be changed due to backwards incompatibility in some cases, then maybe there could be another cmd option, something like --force-base which could be used to set the base even if gruntfile is provided.

thuva4 commented 6 years ago

Any update on this issue?