Skip to content

Instantly share code, notes, and snippets.

@michaelneale
Created July 12, 2011 10:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelneale/1077729 to your computer and use it in GitHub Desktop.
Save michaelneale/1077729 to your computer and use it in GitHub Desktop.
Call make when files change
#!/usr/bin/env ruby
#
# Will monitor a directory for changes, call make when picked up (after a tiny pause)
#
def new_timestamp()
timestamps = Dir.glob("./src/*.erl").map do |m| File.atime(m).to_i end
timestamps.inject { |i,j| i + j }
end
previous = 0
while(true)
newtime = new_timestamp()
if newtime != previous then
sleep(0.1)
puts `make`
previous = new_timestamp()
end
sleep(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment