[英]Guard: batch watch notifications
Although this doesn't batch changes and therefore doesn't have all the benefits of doing so, if all you need to do is prevent multiple builds after several files are saved at once, you can use a debounce mechanism such as the following: 虽然这不是批量更改,因此没有这样做的所有好处,如果你需要做的就是在一次保存多个文件后阻止多次构建,你可以使用去抖动机制,如下所示:
LAST_REBUILD = Time.now
DEBOUNCE = 2 #seconds
guard :shell do
watch(%r{PATTERN}) do |m|
since_last = Time.now - LAST_REBUILD
if since_last > DEBOUNCE
n 'Rebuilding'
if system('LONG_RUNNING_PROCESS')
n 'Build complete'
LAST_REBUILD = Time.now
end
else
n "Skipping rebuild after only #{since_last} seconds"
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.