Make relative paths found in config files relative to said config file, instead of relative to where the command is ran.
(script_path: Path | str, *, relative_to: Path | str)
| 626 | |
| 627 | |
| 628 | def relative_path(script_path: Path | str, *, relative_to: Path | str) -> Path: |
| 629 | """ |
| 630 | Make relative paths found in config files relative to said config file, |
| 631 | instead of relative to where the command is ran. |
| 632 | """ |
| 633 | script_path = Path(script_path) |
| 634 | # Edge case when $HOME is not an absolute path |
| 635 | if script_path.expanduser() != script_path and not script_path.is_absolute(): |
| 636 | script_path = script_path.expanduser().absolute() |
| 637 | return (relative_to / script_path.expanduser()).absolute() |