![](/img/trans.png)
[英]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.