Skip to content

Commit

Permalink
fix(project): add home directory support and enforce absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
entelecheia committed Aug 6, 2023
1 parent 5d7805a commit a948d3a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/hyfi/path/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ class ProjectPathConfig(BasePathConfig):
project_root: str = "."
project_workspace_name: str = "workspace"

@property
def home_dir(self) -> Path:
"""
Return the path to the home directory.
Returns:
path to the home directory
"""
return Path(self.home).absolute() if self.home else Path.home()

@property
def global_root_dir(self) -> Path:
"""
Expand All @@ -32,6 +42,8 @@ def global_root_dir(self) -> Path:
path to the hyfi directory
"""
path_ = Path(self.global_hyfi_root)
if not path_.is_absolute():
path_ = self.home_dir / path_
path_.mkdir(parents=True, exist_ok=True)
return path_

Expand Down Expand Up @@ -144,7 +156,7 @@ def root_dir(self) -> Path:
"""
path_ = Path(self.project_root)
path_.mkdir(parents=True, exist_ok=True)
return path_
return path_.absolute()

@property
def workspace_dir(self) -> Path:
Expand Down

0 comments on commit a948d3a

Please sign in to comment.