Skip to content

Commit efcbea0

Browse files
dbohdannat-n
andauthored
Fix ordered substitution of templated variables in env vars config (#227)
Fixes #223 --------- Co-authored-by: Nat Noordanus <[email protected]>
1 parent f863aa8 commit efcbea0

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

poethepoet/env/manager.py

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def apply_env_config(
116116
self._vars[key] = apply_envvars_to_template(
117117
value_str, scoped_env, require_braces=True
118118
)
119+
scoped_env.set(key, self._vars[key])
119120

120121
def update(self, env_vars: Mapping[str, Any]):
121122
# ensure all values are strings

tests/test_env_config.py

+20
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,23 @@ def test_global_env_templating(temp_pyproject, run_poe_subproc):
3232
}
3333
for value in printed_vars.values():
3434
assert value.endswith(str(project_path)[5:])
35+
36+
37+
EXAMPLE_WITH_ENV_COMPOSITION = """
38+
[tool.poe.env]
39+
BASE_DIR = "/foo"
40+
SUBDIR = "${BASE_DIR}/bar"
41+
FILE = "${SUBDIR}/baz"
42+
43+
[tool.poe.tasks.frobnicate]
44+
expr = "${FILE}"
45+
"""
46+
47+
48+
def test_substitution_in_envvar(temp_pyproject, run_poe_subproc):
49+
project_path = temp_pyproject(EXAMPLE_WITH_ENV_COMPOSITION)
50+
result = run_poe_subproc("frobnicate", cwd=project_path)
51+
52+
assert result.capture == "Poe => ${FILE}\n"
53+
assert result.stdout == "/foo/bar/baz\n"
54+
assert result.stderr == ""

0 commit comments

Comments
 (0)