javascriptnode.jsgruntjsgrunt-plugins

Grunt plugin not overwriting task level options


The GruntJs docs say that target level options should overwrite task level options.

I have built a plugin, grunt-esri-slurp, where I would like to have multiple targets (local dev and for travis ci). I have noticed that the task level options are not being overwritten by the target level options.

esri_slurp: {
  options: {
    version: '3.10',
    beautify: true
  },
  travis: {
    options: {
      beautify: false,
      version: '3.9'
    }
  }
}

when i run grunt esri_slurp:travis 3.10 is passed in as well as beautify. I used a yeoman generator to create the plugin and I don't know if I have to do something in the plugin itself to make this work. This would be the offending code I would imagine.

Is this a grunt bug or developer/user misunderstanding/error?


Solution

  • You need to change your grunt.registerTask call to grunt.registerMultiTask, as that's the one that supports target options.

    Make sure to read the this.options docs.