Fix project lookup on windows.
This commit is contained in:
parent
8a2024bc1c
commit
548a35ffa1
|
@ -1,13 +1,14 @@
|
||||||
import os
|
import os
|
||||||
from typing import Optional
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def root() -> Optional[str]:
|
def root() -> str | None:
|
||||||
cwd = os.getcwd()
|
cwd = Path.cwd()
|
||||||
while cwd != "/":
|
while cwd != Path.root:
|
||||||
if os.path.isfile(os.path.join(cwd, "project.json")):
|
if (cwd / "project.json").is_file():
|
||||||
return cwd
|
return str(cwd)
|
||||||
cwd = os.path.dirname(cwd)
|
cwd = cwd.parent
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ def chdir() -> None:
|
||||||
projectRoot = root()
|
projectRoot = root()
|
||||||
if projectRoot is None:
|
if projectRoot is None:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"No project.json found in this directory or any parent directory")
|
"No project.json found in this directory or any parent directory"
|
||||||
|
)
|
||||||
|
|
||||||
os.chdir(projectRoot)
|
os.chdir(projectRoot)
|
||||||
|
|
Loading…
Reference in a new issue