Skip to content

Commit ecb9991

Browse files
committed
fixed missing destination parent folder if it doesn't exist
1 parent ec186d1 commit ecb9991

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "stacks"
3-
version = "2.0.10"
3+
version = "2.0.11"
44
description = "Stacks, the Terraform code pre-processor"
55
readme = "README.md"
66
requires-python = ">=3.10"

src/stacks/cmd/preinit.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ def preinit(ctx):
2424
helpers.copy_files(ctx.stacks_dir, ctx.work_dir, include=["*.tf", "*.tfvars.jinja"], prefix="common_")
2525
helpers.copy_files(ctx.stack_dir, ctx.work_dir, include=["*.tfvars.jinja"], prefix="stack_")
2626
for item in ctx.base_dir.iterdir():
27+
destination = ctx.work_dir.joinpath(item.name)
2728
if item.is_dir():
28-
shutil.copytree(item, ctx.work_dir.joinpath(item.name), dirs_exist_ok=True)
29+
shutil.copytree(item, destination, dirs_exist_ok=True)
2930
elif item.is_file() and not item.match("*.tf"):
30-
shutil.copyfile(item, ctx.work_dir.joinpath(item.name))
31+
destination.parent.mkdir(parents=True, exist_ok=True)
32+
shutil.copyfile(item, destination)
3133
helpers.copy_files(ctx.base_dir, ctx.work_dir, include=["*.tf"], prefix="base_")
3234
helpers.copy_files(ctx.path, ctx.work_dir, include=["*.tfvars.jinja"], prefix="layer_")
3335

0 commit comments

Comments
 (0)