From 762cd77e65140a36a77a6e70c0081a675f78dea7 Mon Sep 17 00:00:00 2001 From: Taylor Glaeser Date: Sun, 28 Apr 2024 16:44:02 -0500 Subject: [PATCH 1/2] feat: add support for specifying path to node in settings. --- st3/lsp_utils/node_runtime.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/st3/lsp_utils/node_runtime.py b/st3/lsp_utils/node_runtime.py index 824c916..a5c1eec 100755 --- a/st3/lsp_utils/node_runtime.py +++ b/st3/lsp_utils/node_runtime.py @@ -123,6 +123,20 @@ def _resolve_node_runtime( break except Exception as ex: log_lines.append(' * {}'.format(ex)) + elif path.basename(runtime_type) == 'node': + log_lines.append('Resolving Node.js Runtime from absolute path for package {}...'.format(package_name)) + path_runtime = NodeRuntimeAbsolute(runtime_type) + try: + path_runtime.check_binary_present() + except Exception as ex: + log_lines.append(' * Failed: {}'.format(ex)) + continue + try: + path_runtime.check_satisfies_version(required_node_version) + resolved_runtime = path_runtime + break + except Exception as ex: + log_lines.append(' * {}'.format(ex)) if not resolved_runtime: log_lines.append('--- lsp_utils Node.js resolving end ---') print('\n'.join(log_lines)) @@ -226,6 +240,13 @@ def npm_command(self) -> List[str]: return [self._npm] +class NodeRuntimeAbsolute(NodeRuntime): + def __init__(self, node_binary: str): + super().__init__() + self._base_dir = path.abspath(path.dirname(node_binary)) + self._node = path.join(self._base_dir, 'node') + self._npm = path.join(self._base_dir, 'npm') + class NodeRuntimePATH(NodeRuntime): def __init__(self) -> None: super().__init__() From 9bfd9b7f030d8d5139462c6b86d1d551f934f129 Mon Sep 17 00:00:00 2001 From: Taylor Glaeser Date: Tue, 21 May 2024 15:25:25 -0500 Subject: [PATCH 2/2] fix: add `_additional_paths` to `NodeRuntimeAbsolute` --- st3/lsp_utils/node_runtime.py | 1 + 1 file changed, 1 insertion(+) diff --git a/st3/lsp_utils/node_runtime.py b/st3/lsp_utils/node_runtime.py index a5c1eec..e18227c 100755 --- a/st3/lsp_utils/node_runtime.py +++ b/st3/lsp_utils/node_runtime.py @@ -246,6 +246,7 @@ def __init__(self, node_binary: str): self._base_dir = path.abspath(path.dirname(node_binary)) self._node = path.join(self._base_dir, 'node') self._npm = path.join(self._base_dir, 'npm') + self._additional_paths = [path.dirname(self._node)] if self._node else [] class NodeRuntimePATH(NodeRuntime): def __init__(self) -> None: