mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 05:55:41 +08:00
improve watching logic
This commit is contained in:
parent
dfe3ecb914
commit
eaae72c3e4
@ -148,8 +148,7 @@ class Autospec::Manager
|
|||||||
puts "@@@@@@@@@@@@ listen_for_changes" if @debug
|
puts "@@@@@@@@@@@@ listen_for_changes" if @debug
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
ignore: /^public|^lib\/autospec/,
|
ignore: /^lib\/autospec/,
|
||||||
relative_paths: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if @opts[:force_polling]
|
if @opts[:force_polling]
|
||||||
@ -157,11 +156,20 @@ class Autospec::Manager
|
|||||||
options[:latency] = @opts[:latency] || 3
|
options[:latency] = @opts[:latency] || 3
|
||||||
end
|
end
|
||||||
|
|
||||||
Thread.start do
|
path = File.expand_path(File.dirname(__FILE__) + "../../..")
|
||||||
Listen.to('.', options) do |modified, added, _|
|
|
||||||
process_change([modified, added].flatten.compact)
|
# to speed up boot we use a thread
|
||||||
|
Thread.new do
|
||||||
|
["spec", "lib", "app", "config", "test", "vendor", "plugins"].each do |watch|
|
||||||
|
Listen.to("#{path}/#{watch}", options) do |modified, added, _|
|
||||||
|
paths = [modified, added].flatten
|
||||||
|
paths.compact!
|
||||||
|
paths.map!{|long| long[(path.length+1)..-1]}
|
||||||
|
process_change(paths)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_change(files)
|
def process_change(files)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user