-
-
Save rf-/4694347 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# grd: micro Guard. | |
# | |
# Watch one or more filename patterns and then run the given command every time | |
# something changes. | |
# | |
# Example: | |
# grd my_model "rspec spec/models/my_model_spec.rb" | |
require 'listen' | |
unless ARGV[0] && ARGV[1] | |
puts 'USAGE: grd pattern1,pattern2,pattern3 "some command"' | |
exit 1 | |
end | |
files = ARGV[0].split(',').map { |f| Regexp.new(Regexp.escape(f)) } | |
Listen.to('.', filter: files) { system ARGV[1] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment