lib/jim/cli.rb in jim-0.3.2 vs lib/jim/cli.rb in jim-0.3.3

- old
+ new

@@ -44,11 +44,11 @@ # set the default jimhome self.jimhome = Pathname.new(options[:jimhome] || ENV['JIMHOME'] || '~/.jim').expand_path # parse the options self.jimfile = Pathname.new(options[:jimfile] || 'Jimfile').expand_path self.force = options[:force] - self.debug = self.class.debugging || options[:debug] + self.debug = self.class.respond_to?(:debugging) ? self.class.debugging : options[:debug] logger.level = Logger::DEBUG if self.debug end desc 'init [APPDIR]', 'Create an example Jimfile at path or the current directory if path is omitted' @@ -209,28 +209,29 @@ desc "watch [DIR]", "Watches your Jimfile and JS files and triggers `bundle` if something " + "changes. Handy for development." def watch(dir = nil) - require 'fssm' + require 'listen' run_update = lambda {|type, path| unless bundler.bundle_paths.any? {|p| path.include?(p) } say("--> #{path} #{type}") system "jim bundle" end } say "Now watching JS files..." run_update["started", 'Jimfile'] - FSSM.monitor(Dir.pwd, [File.join('**','*.js'), 'Jimfile']) do - update do |base, relative| + dir ||= Dir.pwd + Listen.to(File.expand_path(dir), :filter => /(\.js$|Jimfile)/) do |modified, added, removed| + modified.each do |relative| run_update["changed", relative] end - create do |base, relative| + added.each do |relative| run_update["created", relative] end - delete do |base, relative| + removed.each do |relative| run_update["deleted", relative] end end end