1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-11-14 05:25:12 +00:00

Allow --js-runtimes to accept path to binary or directory (#14964)

Fix 6224a38988

Authored by: bashonly
This commit is contained in:
bashonly
2025-11-09 09:14:22 -06:00
committed by GitHub
parent c63b4e2a2b
commit 4b4223b436
3 changed files with 28 additions and 16 deletions

View File

@@ -2,6 +2,7 @@ from __future__ import annotations
import abc
import dataclasses
import functools
import os.path
from ._utils import _get_exe_version_output, detect_exe_version, int_or_none
@@ -12,6 +13,14 @@ def runtime_version_tuple(v):
return tuple(int_or_none(x, default=0) for x in v.split('.'))
def _determine_runtime_path(path, basename):
if not path:
return basename
if os.path.isdir(path):
return os.path.join(path, basename)
return path
@dataclasses.dataclass(frozen=True)
class JsRuntimeInfo:
name: str
@@ -38,7 +47,7 @@ class DenoJsRuntime(JsRuntime):
MIN_SUPPORTED_VERSION = (2, 0, 0)
def _info(self):
path = self._path or 'deno'
path = _determine_runtime_path(self._path, 'deno')
out = _get_exe_version_output(path, ['--version'])
if not out:
return None
@@ -53,7 +62,7 @@ class BunJsRuntime(JsRuntime):
MIN_SUPPORTED_VERSION = (1, 0, 31)
def _info(self):
path = self._path or 'bun'
path = _determine_runtime_path(self._path, 'bun')
out = _get_exe_version_output(path, ['--version'])
if not out:
return None
@@ -68,7 +77,7 @@ class NodeJsRuntime(JsRuntime):
MIN_SUPPORTED_VERSION = (20, 0, 0)
def _info(self):
path = self._path or 'node'
path = _determine_runtime_path(self._path, 'node')
out = _get_exe_version_output(path, ['--version'])
if not out:
return None
@@ -83,7 +92,7 @@ class QuickJsRuntime(JsRuntime):
MIN_SUPPORTED_VERSION = (2023, 12, 9)
def _info(self):
path = self._path or 'qjs'
path = _determine_runtime_path(self._path, 'qjs')
# quickjs does not have --version and --help returns a status code of 1
out = _get_exe_version_output(path, ['--help'], ignore_return_code=True)
if not out: