[英]In a grunt plugin, how do I get the combination of a global and target specifc option that's an array?
[英]Get a Grunt plugin's target
我正在构建一个Grunt插件,并且需要在Gruntfile.js
选择一个目标。
Gruntfile.js:
grunt.initConfig({
plugin: {
options: {},
target: {} // <= This is what I want to select
}
});
在task / plugin.js内部,我可以使用options = this.options()
来获取options
对象,但是我不能只使用this.target
。 有什么想法吗?
Grunt仅针对多任务公开this.target
。 要访问定时任务( 巴在相同的值grunt foo:bar
),访问args数组代替: this.args[0]
更新:
先前的答案是根据Grunt的官方术语写的。 重新阅读您的问题,您将使用grunt.config()
方法访问config对象中的属性,并 grunt.config()
研究您要在grunt config对象中尝试访问的特定属性。 基于上面的grunt.initConfig
,您可以使用grunt.config('plugin.target');
访问target
的内容grunt.config('plugin.target');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.