Skip to content

Instantly share code, notes, and snippets.

@rf-
Created June 8, 2011 06:17
Show Gist options
  • Save rf-/1013882 to your computer and use it in GitHub Desktop.
Save rf-/1013882 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
out_path = ARGV[0]
in_path = ARGV[1]
glob = "#{in_path}/**/*.coffee"
cmd = "coffee -o #{out_path} -c #{in_path}"
current_mtime = Time.now
def modified?(glob)
mtime = last_mtime(glob)
if current_mtime != mtime
current_mtime = mtime
true
else
false
end
end
def last_mtime(glob)
Dir[glob].map { |f| File.mtime(f) }.max
end
loop do
if modified?(glob)
puts "Recompiling..."
system(cmd)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment