Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.

Commit aa3026e

Browse files
committed
Simplify report capture - use closure to access status_report
Just capture status_report as a local variable before at_exit block. Ruby closures allow the at_exit block to access the outer scope variable. Much simpler than module variables or separate classes.
1 parent 5c00f2b commit aa3026e

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Dangerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ require 'English'
1010
# --------------------------------------------------------------------------------------------------------------------
1111
# Automatically export danger report when Dangerfile finishes
1212
# --------------------------------------------------------------------------------------------------------------------
13+
# Capture status_report for use in at_exit block
14+
report = status_report
15+
1316
at_exit do
1417
# Only skip if there's an actual exception (not SystemExit from danger calling exit)
1518
next if $ERROR_INFO && !$ERROR_INFO.is_a?(SystemExit)
1619

17-
# Export the danger report
18-
# The status_report method is available from the Dangerfile DSL
19-
if defined?(Danger) && defined?(status_report)
20-
reporter = RubyGrapeDanger::Reporter.new(status_report)
20+
# Export the danger report captured above
21+
if report
22+
reporter = RubyGrapeDanger::Reporter.new(report)
2123
reporter.export_json(
2224
ENV.fetch('DANGER_REPORT_PATH', nil),
2325
ENV.fetch('GITHUB_EVENT_PATH', nil)

0 commit comments

Comments
 (0)