fix: path expansion on windows (#1207)

This commit is contained in:
John Sun 2024-06-12 00:22:21 +10:00 committed by GitHub
parent 546e06e654
commit aec70d3d1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 0 deletions

View File

@ -27,8 +27,26 @@ def env():
return "env"
def path(expression):
# In windows we cannot add vars like $$EXT_BUILD_DEPS$$ directly to PATH as PATH is
# required to be in unix format. This implementation also assumes that the vars
# like $$EXT_BUILD_DEPS$$ are exported to the ENV.
expression = _path_var_expansion(expression)
return "export PATH=\"{expression}:$PATH\"".format(expression = expression)
def _path_var_expansion(expression):
result = []
parts = expression.split("$$")
if len(parts) < 3:
return expression
for index, part in enumerate(parts):
if index % 2 == 0:
result.append(part)
else:
result.append("${" + part + "/:/}")
return "/" + "".join(result)
def touch(path):
return "touch " + path