Skip to content

Commit ec10e68

Browse files
committed
remove hacky workarounds for calling node now that there's an api for it
1 parent d6d39c5 commit ec10e68

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

basedpyright/run_node.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import sys
44
from pathlib import Path
55

6-
from nodejs_wheel import executable # pyright:ignore[reportMissingTypeStubs]
6+
from nodejs_wheel.executable import ( # pyright:ignore[reportMissingTypeStubs]
7+
node, # pyright:ignore[reportUnknownVariableType]
8+
)
79

810

911
def run(script_name: str):
10-
sys.exit(executable.call_node(Path(__file__).parent / f"{script_name}.js", *sys.argv[1:])) # pyright:ignore[reportUnknownMemberType]
12+
sys.exit(node([Path(__file__).parent / f"{script_name}.js", *sys.argv[1:]]))

pdm_build.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
from __future__ import annotations
22

3-
import sys
43
from json import loads
54
from pathlib import Path
65
from shutil import copyfile, copytree
7-
from subprocess import run # noqa: S404
86
from typing import TypedDict, cast
97

10-
from nodejs_wheel.executable import ROOT_DIR # pyright:ignore[reportMissingTypeStubs]
11-
12-
node_exe = Path(ROOT_DIR, ("node.exe" if sys.platform == "win32" else "bin/node"))
13-
14-
npm_script = Path(ROOT_DIR, "lib", "node_modules", "npm", "bin", "npm-cli.js")
15-
16-
17-
# Remove when https://github.com/njzjz/nodejs-wheel/pull/24 is merged
18-
def npm(cmd: list[str]):
19-
_ = run([node_exe, npm_script, *cmd], check=True) # noqa: S603
8+
from nodejs_wheel.executable import ( # pyright:ignore[reportMissingTypeStubs]
9+
npm, # pyright:ignore[reportUnknownVariableType]
10+
)
2011

2112

2213
class PackageJson(TypedDict):
2314
bin: dict[str, str]
2415

2516

26-
npm(["ci"])
27-
npm(["run", "build:cli:dev"])
17+
def run_npm(*args: str):
18+
exit_code = npm(args)
19+
if exit_code != 0:
20+
raise Exception(f"the following npm command exited with {exit_code=}: {args}")
21+
22+
23+
run_npm("ci")
24+
run_npm("run", "build:cli:dev")
2825

2926
npm_package_dir = Path("packages/pyright")
3027
pypi_package_dir = Path("basedpyright")

0 commit comments

Comments
 (0)