Class: WpFire::WatchCommand

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/wp_fire/main_command.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/wp_fire/main_command.rb', line 40

def execute
  @assets_path = File.join(dir,"source","assets")
  @templates_path = File.join(dir,"source","templates")
  @functions_path = File.join(dir,"source","functions")

  if build_path and File.directory?(build_path)
    @build_path = build_path
  else
    @build_path = dir
  end

  Dir[File.join(dir,"*")].each do |f|
    unless File.directory?(f)
      File.unlink f unless File.basename(f).eql? "config.rb"
    else
      FileUtils.rm_rf(f) unless File.basename(f).eql? "source"
    end
  end
  watch_directories = [@assets_path,@templates_path,@functions_path]
  WpFire::Compiler.compile_all watch_directories, @build_path

  FileWatcher.new(watch_directories,"Watching files:").watch do |filename|
    WpFire::Compiler.compile filename, @build_path
  end
end