Support list-based commands for RuntimeDependency installation

(preferable on Windows where spaces in paths can cause problems)

Apply list-based commands in TypeScriptLanguageServer
  * for launch command
  * for runtime dependency installation
This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2025-07-28 17:15:27 +02:00
1 parent 66b17cd9e2
commit c08a9b6e55
2 files changed
+14 -6

No files matched your search

+10 -2
View File
@@ -2,6 +2,7 @@ from __future__ import annotations
import logging
import os
import platform
import subprocess
from collections.abc import Sequence
from dataclasses import dataclass
@@ -21,7 +22,7 @@ class RuntimeDependency:
url: str | None = None
archive_type: str | None = None
binary_name: str | None = None
command: str | None = None
command: str | list[str] | None = None
package_name: str | None = None
package_version: str | None = None
extract_path: str | None = None
@@ -71,7 +72,7 @@ class RuntimeDependencyCollection:
return results
@staticmethod
def _run_command(command: str, cwd: str) -> None:
def _run_command(command: str | list[str], cwd: str) -> None:
kwargs = {}
if PlatformUtils.get_platform_id().is_windows():
kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW # type: ignore
@@ -80,6 +81,13 @@ class RuntimeDependencyCollection:
kwargs["user"] = pwd.getpwuid(os.getuid()).pw_name
log.info("Running command '%s' in '%s'", command, cwd)
is_windows = platform.system() == "Windows"
if not isinstance(command, str) and not is_windows:
# Since we are using the shell, we need to convert the command list to a single string
# on Linux/macOS
command = " ".join(command)
completed_process = subprocess.run(
command,
shell=True,
@@ -73,7 +73,7 @@ class TypeScriptLanguageServer(SolidLanguageServer):
@classmethod
def _setup_runtime_dependencies(
cls, logger: LanguageServerLogger, config: LanguageServerConfig, solidlsp_settings: SolidLSPSettings
) -> str:
) -> list[str]:
"""
Setup runtime dependencies for TypeScript Language Server and return the command to start the server.
"""
@@ -95,13 +95,13 @@ class TypeScriptLanguageServer(SolidLanguageServer):
RuntimeDependency(
id="typescript",
description="typescript package",
command="npm install --prefix ./ typescript@5.5.4",
command=["npm", "install", "--prefix", "./", "typescript@5.5.4"],
platform_id="any",
),
RuntimeDependency(
id="typescript-language-server",
description="typescript-language-server package",
command="npm install --prefix ./ typescript-language-server@4.3.3",
command=["npm", "install", "--prefix", "./", "typescript-language-server@4.3.3"],
platform_id="any",
),
]
@@ -131,7 +131,7 @@ class TypeScriptLanguageServer(SolidLanguageServer):
raise FileNotFoundError(
f"typescript-language-server executable not found at {tsserver_executable_path}, something went wrong with the installation."
)
return f"{tsserver_executable_path} --stdio"
return [tsserver_executable_path, "--stdio"]
@staticmethod
def _get_initialize_params(repository_absolute_path: str) -> InitializeParams: