Skip to content

Commit

Permalink
Merge pull request #955 from jameshurst/master
Browse files Browse the repository at this point in the history
Use shutil.which result to run npm
  • Loading branch information
krassowski authored Oct 8, 2023
2 parents 71d99c2 + ed7cb9f commit 018b8f4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions python_packages/jupyter_lsp/jupyter_lsp/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ def _default_nodejs(self):
)

@lru_cache(maxsize=1)
def _npm_prefix(self):
def _npm_prefix(self, npm: Text):
try:
return (
subprocess.run(["npm", "prefix", "-g"], check=True, capture_output=True)
subprocess.run([npm, "prefix", "-g"], check=True, capture_output=True)
.stdout.decode("utf-8")
.strip()
)
Expand Down Expand Up @@ -274,8 +274,9 @@ def _default_node_roots(self):
roots += [pathlib.Path(sys.prefix)]

# check for custom npm prefix
if shutil.which("npm"):
prefix = self._npm_prefix()
npm = shutil.which("npm")
if npm:
prefix = self._npm_prefix(npm)
if prefix:
roots += [ # pragma: no cover
pathlib.Path(prefix) / "lib",
Expand Down

0 comments on commit 018b8f4

Please sign in to comment.