diff --git a/sphinx_js/analyzer_utils.py b/sphinx_js/analyzer_utils.py index 9fbe33f..4b1bec6 100644 --- a/sphinx_js/analyzer_utils.py +++ b/sphinx_js/analyzer_utils.py @@ -14,6 +14,14 @@ def program_name_on_this_platform(program: str) -> str: """Return the name of the executable file on the current platform, given a command name with no extension.""" + + if os.access(program, os.X_OK): + return program + + path = shutil.which(program) + if path and os.access(path, os.X_OK): + return path + return program + ".cmd" if os.name == "nt" else program diff --git a/sphinx_js/typedoc.py b/sphinx_js/typedoc.py index 0bd1836..b29adfb 100644 --- a/sphinx_js/typedoc.py +++ b/sphinx_js/typedoc.py @@ -27,8 +27,11 @@ @cache def typedoc_version_info(typedoc: str) -> tuple[tuple[int, ...], tuple[int, ...]]: + command = Command("node") + command.add(typedoc) + command.add("--version") result = subprocess.run( - [typedoc, "--version"], + command.make(), capture_output=True, encoding="utf8", check=True,