【发布时间】:2014-04-24 16:13:10
【问题描述】:
有没有办法根据更改的文件动态指定要运行的任务?
换句话说:
watch: {
exec: {
files: [html/*.html],
tasks: ['exec:my_exec_task:THE_FILE_THAT_CHANGED']
}
}
我可以捕获监视事件,但我无法从回调中运行任务,因为它“做错了”。
grunt.event.on('watch', function(action, filepath, target) {
if (target === 'exec') {
grunt.task.run('exec:my_exec_task:' + filepath); /* this doesn't work */
grunt.config('filepath', filepath); /* and neither does this, it's undefined in my exec task */
}
});
至少文档是这么说的:https://github.com/gruntjs/grunt-contrib-watch#using-the-watch-event
有什么想法吗?
【问题讨论】:
标签: gruntjs grunt-contrib-watch