lib/jruby_art/runners/watch.rb in jruby_art-2.2.2 vs lib/jruby_art/runners/watch.rb in jruby_art-2.3.0

- old
+ new

@@ -1,6 +1,7 @@ # frozen_string_literal: false + require_relative 'base' require_relative '../config' module Processing class WatchException < StandardError @@ -19,13 +20,14 @@ increase MAX_WATCH in ~/.jruby_art/config.yml EOS SLEEP_TIME = 0.2 def initialize - count = Dir["**.*rb"].length + count = Dir['**.*rb'].length max_watch = RP_CONFIG.fetch('MAX_WATCH', 20) - return warn format(WATCH_MESSAGE, max_watch, count) if count > max_watch.to_i + abort format(WATCH_MESSAGE, max_watch, count) if count > max_watch.to_i + reload_files_to_watch @time = Time.now start_watching end @@ -34,11 +36,11 @@ def start_watching start_original Kernel.loop do if @files.find { |file| FileTest.exist?(file) && File.stat(file).mtime > @time } puts 'reloading sketch...' - Processing.app && Processing.app.close + Processing.app&.close java.lang.System.gc @time = Time.now start_runner reload_files_to_watch end @@ -64,10 +66,10 @@ end end end def start_runner - @runner.kill if @runner && @runner.alive? + @runner.kill if @runner&.alive? @runner.join @runner = nil start_original end