Files

37 lines
1.1 KiB
Python

"""Run the repository's Node-based checks with a portable runtime lookup."""
from __future__ import annotations
import os
from pathlib import Path
import shutil
import subprocess
import sys
def find_node() -> str:
explicit = os.environ.get("NODE")
candidates = [
explicit,
shutil.which("node"),
Path.home() / ".cache" / "codex-runtimes" / "codex-primary-runtime" / "dependencies" / "node" / "bin" / "node.exe",
Path.home() / ".cache" / "codex-runtimes" / "codex-primary-runtime" / "dependencies" / "node" / "bin" / "node",
Path(os.environ.get("ProgramFiles", "")) / "nodejs" / "node.exe",
]
for candidate in candidates:
if candidate and Path(candidate).is_file():
return str(candidate)
raise SystemExit(
"Node.js was not found. Install Node.js or set NODE to the executable path."
)
def main() -> int:
if len(sys.argv) < 2:
raise SystemExit("usage: python tools/run_node.py <node arguments...>")
return subprocess.run([find_node(), *sys.argv[1:]], check=False).returncode
if __name__ == "__main__":
raise SystemExit(main())