繁体   English   中英

使用rubyguard gem监视c ++文件

[英]Using ruby guard gem to monitor c++ files

我正在使用此Guardfile来监视.cpp和.h文件,如果有任何更改,请启动make。 只要所有文件都在Guardfile所在的目录中,它就可以很好地工作。

guard 'shell' do
    watch(%r{^\w*\.(h|cpp)$}) do
        `make test` 
    end
end

我想将Guardfile放在项目树的根目录中,并监视每个子目录中的.h和.cpp文件。 是否可以通过更改正则表达式来做到这一点,还是必须在每个子目录中都有一个Guardfile?

(不确定为什么格式化不正确)

您必须安装以下两个gem:

guard
guard-shell

在您要观看文件的目录中创建一个Guardfile

guard 'shell' do 
  watch(%r{^.+\.(h|hpp|cpp)$}) do 
    `make test`
  end 
end

重要的是实际的shell命令(在这里: make test )必须包装在``中

然后运行: > guard

您应该能够通过正则表达式做到这一点。 尝试这个:

guard 'shell' do 
  watch(%r{^.+\.(h|cpp)$}) do 
    make test 
  end 
end

这应匹配应用程序根目录下任何扩展名为.cpp或.h的目录中的文件。 如果要集中到子目录,请尝试^dir/sub/.+\\.(h|cpp)$

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM