cleaner: rewrite node shebangs
This commit is contained in:
parent
df27448ea7
commit
9b4c211625
@ -155,20 +155,25 @@ class Cleaner
|
|||||||
|
|
||||||
sig { void }
|
sig { void }
|
||||||
def rewrite_shebangs
|
def rewrite_shebangs
|
||||||
|
require "language/node"
|
||||||
require "language/perl"
|
require "language/perl"
|
||||||
require "utils/shebang"
|
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 = @formula.prefix.realpath
|
||||||
basepath.find do |path|
|
basepath.find do |path|
|
||||||
Find.prune if @formula.skip_clean? path
|
Find.prune if @formula.skip_clean? path
|
||||||
|
|
||||||
next if path.directory? || path.symlink?
|
next if path.directory? || path.symlink?
|
||||||
|
|
||||||
begin
|
rewrites.each { |rw| Utils::Shebang.rewrite_shebang rw, path }
|
||||||
Utils::Shebang.rewrite_shebang Language::Perl::Shebang.detected_perl_shebang(@formula), path
|
|
||||||
rescue ShebangDetectionError
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user