fix: resolve Node outside daemon PATH
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled
This commit is contained in:
@@ -107,11 +107,41 @@ def libredwg_wasm_module_dir() -> Path | None:
|
||||
return None
|
||||
|
||||
|
||||
def node_executable() -> str | None:
|
||||
"""Resolve Node from env, PATH, or common platform install locations."""
|
||||
override = os.environ.get("NODE")
|
||||
if override:
|
||||
return override if Path(override).exists() else None
|
||||
found = shutil.which("node")
|
||||
if found:
|
||||
return found
|
||||
candidates = []
|
||||
if sys.platform == "darwin":
|
||||
candidates.extend((Path("/opt/homebrew/bin/node"), Path("/usr/local/bin/node")))
|
||||
elif sys.platform == "win32":
|
||||
candidates.extend(
|
||||
Path(path) / "nodejs" / "node.exe"
|
||||
for path in (os.environ.get("ProgramFiles"), os.environ.get("ProgramFiles(x86)"))
|
||||
if path
|
||||
)
|
||||
for candidate in candidates:
|
||||
if candidate.exists():
|
||||
return str(candidate)
|
||||
return None
|
||||
|
||||
|
||||
def run_wasm_libredwg(source: Path, dest: Path, work_dir: Path, vendor_dir: Path) -> dict:
|
||||
"""Convert one DWG through the packaged libredwg WASM bridge."""
|
||||
node = shutil.which("node")
|
||||
node = node_executable()
|
||||
module_dir = libredwg_wasm_module_dir()
|
||||
if not node or module_dir is None:
|
||||
if not node:
|
||||
return {
|
||||
"source": str(source),
|
||||
"dest": str(dest),
|
||||
"status": "missing_node",
|
||||
"message": "Install Node.js or set NODE to its executable path.",
|
||||
}
|
||||
if module_dir is None:
|
||||
return {
|
||||
"source": str(source),
|
||||
"dest": str(dest),
|
||||
|
||||
Reference in New Issue
Block a user