【发布时间】:2013-08-31 21:10:51
【问题描述】:
我正在尝试让 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
CoffeeScript 文件每次被触摸时都会被正确编译到 tmp 目录中,但随后 shell 守卫不会触发。
使用--debug 启动保护并手动更改tmp 中的一个JS 文件,我在终端中没有得到任何调试行。这些文件似乎没有被监控。
$ 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)>
^^^ 如果我此时修改/home/tobia/my_project/tmp 中的JS文件,则没有任何反应。
我正在使用来自 Debian stable 的 Ruby 1.9.1、Guard 1.8.2 和 Guard-shell 0.5.1 并安装了sudo gem install
【问题讨论】:
-
尽量减少正则表达式的限制,例如%r{tmp/.+\.js$}
-
试过
%r{tmp/.+\.js},还是没有。我应该告诉 Guard 以某种方式“监视” tmp 目录吗?我只是手动修改了一个js文件,Guard什么都没有打印出来。
标签: ruby coffeescript guard