From 09f7b84d61bee0543c12f23a40ad847c2888fd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Fri, 24 Oct 2025 09:38:46 +0200 Subject: [PATCH] remove bash -lc --- npm_install.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/npm_install.py b/npm_install.py index f578763..309206e 100644 --- a/npm_install.py +++ b/npm_install.py @@ -588,13 +588,24 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path): import shutil as _s return _s.which(cmd) is not None - yarn = "yarn" if _which("yarn") else ("yarnpkg" if _which("yarnpkg") else "") + def _good_yarn(cmd: str) -> bool: + out = (run_out([cmd, "--version"], check=False) or "").strip() + return bool(re.match(r"^\d+(?:\.\d+){1,3}$", out)) + + yarn = None + for cand in ("yarn", "yarnpkg"): + if _which(cand) and _good_yarn(cand): + yarn = cand + break if not yarn: run(["corepack", "enable"], check=False) run(["corepack", "prepare", "yarn@stable", "--activate"], check=False) - yarn = "yarn" if _which("yarn") else ("yarnpkg" if _which("yarnpkg") else "") + for cand in ("yarn", "yarnpkg"): + if _which(cand) and _good_yarn(cand): + yarn = cand + break if not yarn: - raise RuntimeError("Brak Yarn. Zainstaluj: npm i -g yarn (lub użyj corepack).") + raise RuntimeError("No yarn in system") with step("Installing frontend dependencies (yarn)"): os.environ["NODE_ENV"] = "development" @@ -602,8 +613,8 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path): cache_dir = (run_out([yarn, "cache", "dir"], check=False) or "").strip() if cache_dir and not Path(cache_dir).exists(): Path(cache_dir).mkdir(parents=True, exist_ok=True) - run([yarn, "cache", "clean"], check=False) + run([yarn, "cache", "clean"], check=False) run([yarn, "install"]) with step("Building frontend (yarn build)"):