Skip to content

Commit

Permalink
Merge pull request #17773 from branchvincent/node-shebangs
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Jul 30, 2024
2 parents 33f555e + 9b4c211 commit cae9660
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 }
end
end

Expand Down

0 comments on commit cae9660

Please sign in to comment.