2013-08-18 40 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