2013-08-18 39 views
1

我想在任何.js文件更改(built.js除外)时运行requirejs优化脚本。Ruby Guard忽略文件

我看到有一个忽略方法。我在Gaurdfile(这导致无限循环)中有以下内容。

guard 'shell', :ignore => 'built.js' do 
    watch(/script\/(.*).js/) { `node r.js -o build.js` } 
end 

我的问题是:如何配置我的Guardfile忽略文件built.js

+1

如果你只是完全想忽略built.js,把它放在文件的顶部(可能带有过滤器),就像你在文档中看到的那样:https://github.com/guard/guard/wiki/Guardfile -例子 。有关过滤器的更多信息(仅考虑.js文件),请参阅此处的文档:https://github.com/guard/guard#filter。有关guard-shell的语法,请参阅https://github.com/guard/guard-shell – RobM

回答

6

首先,假设你已经安装了保护壳的宝石......

我认为这给你的东西,从给你正在尝试做的工作。 当任何其他.js文件更改时,它将忽略script/build.js文件并触发shell命令。

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