简体   繁体   English

Grunt插件不会覆盖任务级别选项

[英]Grunt plugin not overwriting task level options

The GruntJs docs say that target level options should overwrite task level options. GruntJs文档说目标级别选项应该覆盖任务级别选项。

I have built a plugin, grunt-esri-slurp , where I would like to have multiple targets (local dev and for travis ci). 我构建了一个插件grunt-esri-slurp ,在其中我想拥有多个目标(本地开发人员和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 . 当我运行grunt esri_slurp:travis 3.10以及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. 我使用yeoman生成器创建了插件,但我不知道是否必须在插件本身中做一些事情才能使此工作生效。 This would be the offending code I would imagine. 这将是我想像的令人讨厌的代码

Is this a grunt bug or developer/user misunderstanding/error? 这是严重的错误还是开发人员/用户的误解/错误?

You need to change your grunt.registerTask call to grunt.registerMultiTask , as that's the one that supports target options. 您需要将grunt.registerTask调用更改grunt.registerMultiTask ,因为这是支持目标选项的调用。

Make sure to read the this.options docs . 确保阅读this.options文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM