I would like to run the requirejs optimization script when any .js
file is changed (except for built.js
).
I read there is an ignore method. I have the following in my Gaurdfile
(which is causing an infinite loop).
guard 'shell', :ignore => 'built.js' do
watch(/script\/(.*).js/) { `node r.js -o build.js` }
end
My question is: How do I configure my Guardfile
to ignore the file built.js
?
First, assuming you already have the guard-shell gem installed...
I think this gives you something to work from given what you are trying to do. It will ignore the script/build.js file and trigger a shell command when any other .js file changes.
ignore /script\/build.js/
guard :shell do
watch /.*\.js/ do |m|
`yourcommandhere`
msg = "Processed #{m[0]}"
n msg, 'mycustomshellcommand'
"-> #{msg}"
end
end
See this link for Guardfile examples.
See this link for the syntax of guard-shell.