Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for specifying path to node in settings #118

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions st3/lsp_utils/node_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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')
taylorzane marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +247 to +248
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't work on Windows.

self._additional_paths = [path.dirname(self._node)] if self._node else []

class NodeRuntimePATH(NodeRuntime):
def __init__(self) -> None:
super().__init__()
Expand Down