2

我正在尝试让 Guard 将我的 CoffeeScript 文件编译为 JS 文件,然后让 Juicer 合并并缩小它们。我使用一个tmp目录来存储中间 JS 文件。据我了解,这应该有效,但它没有:

guard :coffeescript, :input => "src/coffee", :output => "tmp"

guard :shell do
    watch %r{^tmp/.+\.js$} do
        system 'juicer', 'merge', 'tmp/app.js', '-sfo', 'js/app.js'
    end
end

tmpCoffeeScript 文件每次被触摸时都会被正确编译到目录中,但是shell守卫不会触发。

手动启动保护--debug并更改其中一个 JS 文件tmp,我在终端中没有得到任何调试行。似乎这些文件没有被监视。

$ guard --debug
18:53:51 - DEBUG - Command execution: which notify-send
18:53:51 - DEBUG - Command execution: emacsclient --eval '1' 2> /dev/null || echo 'N/A'
18:53:51 - INFO - Guard is using TerminalTitle to send notifications.
18:53:51 - DEBUG - Command execution: hash stty
18:53:51 - DEBUG - Guard starts all plugins
18:53:51 - DEBUG - Hook :start_begin executed for Guard::CoffeeScript
18:53:51 - DEBUG - Hook :start_end executed for Guard::CoffeeScript
18:53:51 - DEBUG - Hook :start_begin executed for Guard::Shell
18:53:51 - DEBUG - Hook :start_end executed for Guard::Shell
18:53:51 - INFO - Guard is now watching at '/home/tobia/my_project'
18:53:51 - DEBUG - Start interactor
[1] guard(main)> 

^^^ 如果我此时修改 JS 文件/home/tobia/my_project/tmp,则没有任何反应。

我正在使用来自 Debian stable 的 Ruby 1.9.1、Guard 1.8.2 和 Guard-shell 0.5.1 安装sudo gem install

4

1 回答 1

3

经过一番调查,我意识到它tmp在默认的忽略列表中,所以这就是为什么 Guard 不会从生成的 JavaScript 文件中获取更改的原因。要解决此问题,您可以...

1.tmp从忽略目录列表中删除

ignore! /.git/

guard :coffeescript, :input => "src/coffee", :output => "tmp"

guard :shell do
  watch %r{^tmp/.+\.js$} do
    system 'juicer', 'merge', 'tmp/app.js', '-sfo', 'js/app.js'
  end
end

2. 将 JavaScript 编译到不同的目录

guard :coffeescript, :input => "src/coffee", :output => "src/js"

guard :shell do
  watch %r{^src/.+\.js$} do
    system 'juicer', 'merge', 'tmp/app.js', '-sfo', 'js/app.js'
  end
end
于 2013-08-29T11:24:59.897 回答