【发布时间】:2014-11-05 14:44:04
【问题描述】:
我正在尝试在文件更改时运行 shell 命令。获取最后更改的文件以用作 shell 命令的参数。这是代码:
grunt.initConfig({
changedFile: 'test',
watch: {
all: {
files: ['js/*.js'],
tasks: ['shell']
}
},
shell: {
run: {
// it outputs 'test', not changed file
command: 'touch <%= changedFile %>'
}
}
});
grunt.event.on('watch', function(action, filepath) {
grunt.config('changedFile', filepath);
});
'watch' eventListener 确实有效,但它在 shell 命令运行后才有效。如何在事件触发之前运行任务?
【问题讨论】:
标签: gruntjs grunt-contrib-watch