[issue_934] from_shebang tera function uses starts_with (#935)

This allows to cover versioning of language executables, like it can happen for Python. Currently there is python, python2 and python3. Could just add python2.7, but we should add new env item for each new Python version, like python3.4, python3.10, etc which soon may be somewhat cumbersone.
This commit is contained in:
Adam Tokarski 2022-08-15 09:07:59 +02:00 committed by GitHub
parent 54a6200fac
commit 61dd7df6fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -380,7 +380,13 @@ impl LanguageType {
match word {
{% for key, value in languages -%}
{%- if value.env -%}
{%- for item in value.env %}| "{{item}}" {% endfor %}=> Some({{key}}),
{%- for item in value.env %}
{% if loop.index == 1 %}
_ if word.starts_with("{{item}}")
{% else %}
|| word.starts_with("{{item}}")
{% endif %}
{% endfor %}=> Some({{key}}),
{% endif -%}
{%- endfor %}
env => {