Natural Preference for Minification
    Have ideas to improve npm?Join in the discussion! »

    nopt-grunt-fix

    1.0.0 • Public • Published

    nopt-grunt-fix

    Fix arguments parsing for Grunt ~0.4.x

    Overview

    Grunt has a longstanding issue (well, more than one issue) to update to a newer version of nopt and fix the options parsing. But since it's a breaking change it's not going to be implemented until Grunt 0.5.0...

    Well, you don't have to wait, the future is now!

    Add this module to your Gruntfile and it will make Grunt options work just as you'd expect.

    Installation

    $ npm install --save nopt-grunt-fix

    Usage

    At the top of your Gruntfile.js:

    module.exports = function(grunt){
     
        require('nopt-grunt-fix')(grunt);
        
        //...
    }

    That's it!

    Behaviour

    Without nopt-grunt-fix, running:

    $ grunt task1 --no-build --once --no-watch -r=1.10

    will give you:

        grunt.option('no-build') === true  ✓
        grunt.option('once') === '--no-watch'  ✗
        grunt.option('r') === 1.1  ✗
        grunt.option('no-watch') === false  ✗
        grunt.option('watch') === undefined  ✗

    With nopt-grunt-fix, running:

    $ grunt task1 --no-build --once --no-watch -r=1.10

    will give you:

    grunt.option('no-build') === true  ✓
    grunt.option('once') === true  ✓
    grunt.option('r') === '1.10'  ✓
    grunt.option('no-watch') === true  ✓
    grunt.option('watch') === false  ✓

    Debugging

    If you run Grunt with the --debug flag then we'll log out the old and new flags:

    [D] (nopt-grunt-fix) old flags:  [ '--no-build', '--once=--no-watch', '--r=1.1', '--debug=1' ]
    [D] (nopt-grunt-fix) new flags:  [ '--no-build', '--once', '--r=1.10', '--debug=1', '--no-watch' ]
    

    Install

    npm i nopt-grunt-fix

    DownloadsWeekly Downloads

    8,133

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • avatar