【发布时间】:2015-10-03 21:19:11
【问题描述】:
我正在使用grunt-vagrnat-ssh 插件设置一些grunt 任务。
我想避免在提供的示例配置中出现一些不必要的重复。更具体地说,我说的是 path 、 flags 甚至可能是 callback 字段。
我是否有机会为我的所有任务和 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'
],
}
}
});
不幸的是,上面的配置不起作用(至少对我来说),我也尝试过保持原始回调完好无损,但仍然没有运气:(
任何建议将不胜感激:)
【问题讨论】: