我正在使用 Guard 自动监视目录并使用 Guard-Shell 执行一些 bash 脚本,问题是我将 Guardfile 放在与正在监视的文件夹不同的文件夹中,所以我必须使用 guard 和 guard -w/directory/being/watched
.
我的问题是,是否有一个可从 Guardfile 访问的变量会告诉我正在监视的目录?
谢谢。
最佳答案
据此:
https://github.com/guard/guard/wiki/Correctly-using-the---watchdir-option
解决方案是在被监视的目录中运行 guard,但在不同的目录中指定 Guardfile:
cd /directory/being/watched
BUNDLE_GEMFILE=/projects/foo/Gemfile bundle exec guard -G /projects/foo/Guardfile
关于 ruby 守卫 : Is the directory being watched stored in some variable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9072275/