0
我正在使用grunt-vagrnat-ssh插件設置一些grunt任務。如何優化grunt配置
我想避免在提供的示例配置中出現一些不必要的重複次數。更具體地說,我說的是路徑,標誌甚至可能是回調字段。
有沒有可能爲我的所有任務和shell命令定義一次?
基本上改變以下
grunt.initConfig({
vagrantssh: {
addfile: {
path: './.vvv/',
commands: [
'echo "testing" > /tmp/test.txt',
'cat /tmp/test.txt'
],
flags: [ '-t', '-A' ],
callback: function(grunt, output) {
grunt.log.writeln('Output: ' + output);
}
},
removefile: {
path: './.vvv/',
commands: [
'rm -rf /tmp/test.txt',
'cat /tmp/test.txt'
],
flags: [ '-t', '-A' ],
callback: function(grunt, output) {
grunt.log.writeln('Output: ' + output);
}
}
}
});
喜歡的東西
grunt.initConfig({
vagrantssh: {
options: {
path: './.vvv/',
flags: [ '-t', '-A' ],
callback: function(grunt, output) {
grunt.log.writeln('Output: ' + output);
}
},
addfile: {
commands: [
'echo "testing" > /tmp/test.txt',
'cat /tmp/test.txt'
],
},
removefile: {
commands: [
'rm -rf /tmp/test.txt',
'cat /tmp/test.txt'
],
}
}
});
不幸的是,上述配置不工作(至少對我來說),我也沒有嘗試離開原來的回調完好,但仍然沒有運氣:(
任何意見將不勝感激:)