简体   繁体   English

如何防止咕gr咕con的手表自触发?

[英]How to prevent grunt-contrib-watch from self triggering?

I have this grunt task: 我有这个艰巨的任务:

watch: {
  files: ['resources/assets/sass/*.scss'],
  tasks: ['csscomb:sortAll', 'sass:theme', 'sass:mail']
},
csscomb: {
  options: {
    config: 'csscomb.json'
  },
  sortAll: {
    expand: true,
    cwd: '.',
    src: ['resources/assets/sass/*.scss'],
    dist: 'resources/assets/sass/',
    ext: '.scss'        
  }
},

When I save any scss file grunt tries to run the tasks I've specified, but csscomb:sortAll changes scss files and triggers another file change. 当我保存任何scss文件时,grunt会尝试运行指定的任务,但是csscomb:sortAll会更改scss文件并触发另一个文件更改。 the grunt watch runt tasks for the second time and the result is running these three tasks two times instead of once. 咕gr的声音第二次监视矮小任务,结果这三个任务两次运行,而不是一次。 What would you suggest? 你有什么建议?

Just use grunt-newer , so that the second time your task gets called, nothing actually runs: 只需使用grunt-newer ,这样第二次调用任务时,实际上什么也不会运行:

watch: {
  files: ['resources/assets/sass/*.scss'],
  tasks: ['newer:csscomb:sortAll', 'newer:sass:theme', 'newer:sass:mail']
},

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

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