Skip to content

Commit

Permalink
cleaner: rewrite node shebangs
Browse files Browse the repository at this point in the history
  • Loading branch information
branchvincent committed Jul 16, 2024
1 parent df27448 commit 9b4c211
Showing 1 changed file with 10 additions and 5 deletions.
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 @@ def clean_dir(directory)

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

0 comments on commit 9b4c211

Please sign in to comment.