繁体   English   中英

看完声音后如何运行任务?

[英]How to run a task after grunt watch finishes?

每次运行手表后,是否可以选择运行特定任务? 例如

watch : {
  js: {files:[], tasks:[]},
  css: {files:[], tasks:[]},
}

我想在watch:jswatch:css之后都运行任务“ foo”,并且我不想将该任务添加到每个watch多任务任务列表中,并且我不想添加新的watch任务来自其他任务的所有文件都将被监视。

有手表的常规options.afterEach api或其他东西吗?

简短答案 :否

Grunt或Grunt Watch没有内置的方式。 这个github问题讨论了添加下一个版本的可能性。

据我所知,有一个watch事件,但是没有什么象watch:startwatch:end一样。 您可以像下面这样使用此事件:

grunt.event.on('watch', function(action, filepath, target) {
    grunt.log.writeln('Here is the action : ' + action);
    grunt.log.writeln('Here is the filepath : ' + filepath);
});

不幸的是,这仅在开始时运行:

Running "watch" task
Waiting...
Here is the action : changed
Here is the filepath : pre/js/console.js
>> File "pre/js/console.js" changed.
Running "jshint:all" (jshint) task
...

相关问题:

监视任务之后可以运行任务吗?

任务完成后运行命令

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM