値の配列にすることができるオプションを持つgruntプラグインを書いています。値は具体的にはファイルです(タスク自体のfilesプロパティで指定されたファイルとは異なります)。私のタスク設定は次のようになります。
grunt.initConfig({
assemble: {
options: {
data: ['test/common/data/common1.json', 'test/common/data/common2.json']
},
dev: {
options: {
data: ['test/dev/data/dev.json']
},
files: {
'test/actual': ['test/files/dev.hbs']
}
},
prod: {
options: {
data: ['test/prod/data/prod.json']
},
files: {
'test/actual': ['test/files/prod.hbs']
}
},
}
});
私のプラグインでは、グローバルオプションとターゲットオプションで指定されたすべてのファイルのリストを含むデータオプションを取得できるようにしたいと思います。
開発ターゲットの場合、grunt assemble:dev
これは次のように表示されます。this.options.data
['test/common/data/common1.json',
'test/common/data/common2.json',
'test/dev/data/dev.json']
製品ターゲットの場合、grunt assemble:prod
これは次のように表示されます。this.options.data
['test/common/data/common1.json',
'test/common/data/common2.json',
'test/prod/data/prod.json']