Skip to content

Commit ed4fe44

Browse files
committed
Add a beter explanation of how we call the packwerk cli
1 parent c63b69b commit ed4fe44

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/danger-packwerk/packwerk_wrapper.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ module DangerPackwerk
1616
class PackwerkWrapper
1717
extend T::Sig
1818

19+
# This code is partially copied from exe/packwerk within the packwerk gem. We're imitating the
20+
# cli here but with our own offense formatter to collect the violating data directly.
21+
#
22+
# We capture and ignore the output of the Cli so that we don't leak it to the build system logs.
23+
# When packwerk produces errors it can make the build system look like it's failing when really
24+
# this is expected behavior.
1925
sig { params(files: T::Array[String]).returns(T::Array[Packwerk::ReferenceOffense]) }
2026
def self.get_offenses_for_files(files)
2127
formatter = OffensesAggregatorFormatter.new
22-
# This is mostly copied from exe/packwerk within the packwerk gem, but we use our own formatters
2328
ENV['RAILS_ENV'] = 'test'
2429
cli = Packwerk::Cli.new(offenses_formatter: formatter, out: StringIO.new)
2530
cli.execute_command(['check', *files])

0 commit comments

Comments
 (0)