lib/linner/command.rb in linner-0.1.1 vs lib/linner/command.rb in linner-0.1.2

- old
+ new

@@ -16,25 +16,37 @@ end end desc "watch", "watch assets" def watch - proc = Proc.new do |modified, added, removed| + @reactor = Reactor.new + + @proc = Proc.new do |modified, added, removed| begin Notifier.info{ Linner.perform } rescue Notifier.error $! end end - proc.call - listener = Listen.to "app/", "vendor/", "test/", filter: /\.(js|coffee|css|sass|scss)$/ - listener.change &proc + @proc.call + + Listen.to env.app_folder, env.vendor_folder, env.test_folder do |modified, added, removed| + @proc.call + end + + Listen.to env.public_folder, :relative_paths => true do |modified, added, removed| + paths = [].push(modified, added, removed).flatten.compact + @reactor.reload_browser(paths) + end + trap :INT do Notifier.exit + @reactor.stop exit! end - listener.start! + + sleep end desc "clean", "clean assets" def clean FileUtils.rm_rf Dir.glob("#{Linner.environment.public_folder}/*") @@ -42,9 +54,14 @@ desc "new", "create the skeleton of project" def new(name) directory('templates', name) chmod("#{name}/bin/server", 0755) + end + + private + def env + Linner.environment end end end