Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaner: rewrite node shebangs #17773

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Library/Homebrew/cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,25 @@

sig { void }
def rewrite_shebangs
require "language/node"
require "language/perl"
require "utils/shebang"

rewrites = [Language::Node::Shebang.method(:detected_node_shebang),
Language::Perl::Shebang.method(:detected_perl_shebang)].filter_map do |detector|
detector.call(@formula)
rescue ShebangDetectionError
nil
end
return if rewrites.empty?

basepath = @formula.prefix.realpath
basepath.find do |path|
Find.prune if @formula.skip_clean? path

next if path.directory? || path.symlink?

begin
Utils::Shebang.rewrite_shebang Language::Perl::Shebang.detected_perl_shebang(@formula), path
rescue ShebangDetectionError
break
end
rewrites.each { |rw| Utils::Shebang.rewrite_shebang rw, path }

Check warning on line 176 in Library/Homebrew/cleaner.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cleaner.rb#L176

Added line #L176 was not covered by tests
end
end

Expand Down
Loading