Skip to content

Commit

Permalink
fix: handle correctly symlink in directories
Browse files Browse the repository at this point in the history
Signed-off-by: Adrien Mannocci <[email protected]>
  • Loading branch information
amannocci committed Feb 2, 2024
1 parent 51d62da commit d80911a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions terranova/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,18 @@ def init(path: str | None) -> None:

# Create new symbolic links
for dependency in manifest.dependencies:
os.symlink(
os.path.relpath(
SharedContext.shared_dir().joinpath(dependency.source).as_posix(), full_path.as_posix()
),
dependency.target,
)
try:
target_dirname = os.path.dirname(dependency.target)
os.symlink(
os.path.relpath(
SharedContext.shared_dir().joinpath(dependency.source).as_posix(),
full_path.joinpath(target_dirname).as_posix(),
),
dependency.target,
)
except FileExistsError:
# The symlink already exists and it's probably fine
pass
finally:
os.chdir(cwd)

Expand Down

0 comments on commit d80911a

Please sign in to comment.