Is there a way to create a simple guard watch? I want to run a rake task when a file changes in a specific directory and going through all of these steps is too much for this one off task. https://github.com/guard/guard/wiki/Create-a-guard
I tried adding this in the Guardfile but it doesn't work.
guard :doc do
watch(%r{^documentation}) { "rake doc:build" }
end
watch("/documentation") { "rake doc:build" }
So do you know of a simple way to run a rake task when a file is updated with guard?
Guard is a command line tool to easily handle events on file system modifications.
A guard file is another level of security that defines the access rights of various users and programs for access to a program, data file, or database. A guard file can contain one or more access rules. These access rules apply to the file that the guard file is assigned to protect.
The most straightforward way is to use guard-rake to run a Rake task on a file modification.
A more generic solution is to use guard-shell to run any command line tool on a file modification.
More complex use cases should be solved by creating your own guard plugin. You don't even need to create a gem, since you can simply define them as inline guard as Avdi shows us in his a Guardfile for Redis blog post.
When you want to share your Guard, just have a look at more advanced Guard plugins like guard-rspec or guard-jasmine as examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With