Refactor subprocess to cmd.py part 1. Fixed clan_uri test.

This commit is contained in:
Qubasa
2024-01-02 16:34:10 +01:00
parent 1986271bef
commit 9c7f62a4a5
5 changed files with 22 additions and 44 deletions

View File

@@ -1,17 +1,18 @@
import json
import subprocess
from pathlib import Path
from clan_cli.nix import nix_eval
from .cmd import run
def get_clan_module_names(
flake_dir: Path,
) -> tuple[list[str], str | None]:
) -> list[str]:
"""
Get the list of clan modules from the clan-core flake input
"""
proc = subprocess.run(
proc = run(
nix_eval(
[
"--impure",
@@ -25,11 +26,8 @@ def get_clan_module_names(
""",
],
),
capture_output=True,
text=True,
cwd=flake_dir,
)
if proc.returncode != 0:
return [], proc.stderr
module_names = json.loads(proc.stdout)
return module_names, None
return module_names