Skip to content

Instantly share code, notes, and snippets.

@michaelglass
Created February 13, 2014 22:20
Show Gist options
  • Save michaelglass/8985140 to your computer and use it in GitHub Desktop.
Save michaelglass/8985140 to your computer and use it in GitHub Desktop.
guardfile modifications to play nice with zeus on vagrant
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
if Dir.pwd == '/vagrant'
Guard::UI.info 'detected vagrant, enabling force polling'
Guard.options[:force_polling] = true
Guard.listener.options[:force_polling] = true
end
guard 'rspec', cmd: 'zeus rspec', all_on_start: false, all_after_pass: false do
#...
if Guard::options.force_polling
Guard::UI.info "detected forced_polling: will touch test file to ensure zeus restarts"
callback(:run_on_modifications_begin) do |a, b, files|
files.each do |file|
['app', '.'].each do |prefix|
test_target = file.gsub(/spec\/(.+)_spec.rb/, "#{prefix}/\\1.rb")
if File.exists? test_target
Guard::UI.info "touching #{test_target} (for zeus reload)"
FileUtils.touch test_target
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment