3

我已经实现了guard-rubocop gem。我尝试了没有防护的相同宝石。如果没有警卫,我可以将结果写入文件(rubocop -o/--out) rubocop without guard。但是有了 guard 我无法找到带有 guard 的选项 rubocop。任何人都可以教我如何将guard-rubocop 结果写入文件吗?

4

2 回答 2

1

你有没有尝试过

guard :rubocop, cli: ['--out /path/to/output/file'] do
  # ...
end

如文档中所建议

于 2014-01-29T13:09:20.983 回答
1

updated

If you need only rubocop output to file then here is how could be done:

# Guardfile

# set before guard rubocop initialisation
UI.instance_variable_set :@logger, Lumberjack::Logger.new("log/errors.log", UI.options)

guard :rubocop do
  # ...
end

Fix:

instead of hacking, Guard has a official way to set options for logger like (thanks @Netzpirat):

logger device: "log/errors.log"
于 2014-01-29T15:11:04.280 回答