Last active
August 29, 2015 14:21
-
-
Save DannyBen/868952bb0879fb6b990c to your computer and use it in GitHub Desktop.
Ruby Filewatcher Interrupt Bug
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
# See https://github.com/thomasfl/filewatcher/issues/24 | |
$ gem install filewatcher -v0.4.0 | |
$ gem uninstall filewatcher -v0.5.0 | |
$ rvm list | |
$ ruby -v | |
$ gem list filewatcher | |
$ ./test.rb | |
$ gem install filewatcher | |
$ gem list filewatcher | |
$ ./test.rb | |
$ gem uninstall filewatcher -v0.5.0 |
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 | |
# With 0.4.0, Ctrl+C is exiting properly. With 0.5.0 it shows | |
# stack trace | |
# trap("SIGINT") { puts "\033[2K\rGoodbye"; exit } # claener | |
trap("SIGINT") { puts "\nGoodbye"; exit } | |
puts "Watching files..." | |
fork { exec "filewatcher 'test.rb' 'echo changed'" } | |
# In real life this is exec'ing Shopify's "theme watch" command | |
# I copied the bare minimum code from it to the theme.rb file | |
# See https://github.com/Shopify/shopify_theme/search?utf8=%E2%9C%93&q=watcher | |
puts "Watching theme..." | |
fork { exec "./theme.rb" } | |
Process.waitall |
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 | |
require 'filewatcher' | |
def watcher | |
FileWatcher.new(Dir.pwd).watch() do |filename, event| | |
yield(filename, event) | |
end | |
end | |
watcher do |filename, event| | |
puts "changed #{filename}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment