diff --git a/st3/lsp_utils/node_runtime.py b/st3/lsp_utils/node_runtime.py index 824c916..e18227c 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,14 @@ 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') + self._additional_paths = [path.dirname(self._node)] if self._node else [] + class NodeRuntimePATH(NodeRuntime): def __init__(self) -> None: super().__init__()