language: raise ShebangDetectionError rather than a generic error

This commit is contained in:
Bo Anderson
2021-05-10 05:50:08 +01:00
parent 1e567161d1
commit 728bb547a7
3 changed files with 12 additions and 3 deletions
+4 -2
View File
@@ -105,8 +105,10 @@ module Language
def detected_python_shebang(formula = self)
python_deps = formula.deps.map(&:name).grep(/^python(@.*)?$/)
raise "Cannot detect Python shebang: formula does not depend on Python." if python_deps.empty?
raise "Cannot detect Python shebang: formula has multiple Python dependencies." if python_deps.length > 1
raise ShebangDetectionError.new("Python", "formula does not depend on Python") if python_deps.empty?
if python_deps.length > 1
raise ShebangDetectionError.new("Python", "formula has multiple Python dependencies")
end
python_shebang_rewrite_info(Formula[python_deps.first].opt_bin/"python3")
end