Skip to content

Commit

Permalink
remove hacky workarounds for calling node now that there's an api for it
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed May 8, 2024
1 parent f07894d commit cf89836
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
6 changes: 4 additions & 2 deletions basedpyright/run_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import sys
from pathlib import Path

from nodejs_wheel import executable # pyright:ignore[reportMissingTypeStubs]
from nodejs_wheel.executable import ( # pyright:ignore[reportMissingTypeStubs]
node, # pyright:ignore[reportUnknownVariableType]
)


def run(script_name: str):
sys.exit(executable.call_node(Path(__file__).parent / f"{script_name}.js", *sys.argv[1:])) # pyright:ignore[reportUnknownMemberType]
sys.exit(node([Path(__file__).parent / f"{script_name}.js", *sys.argv[1:]]))
25 changes: 11 additions & 14 deletions pdm_build.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
from __future__ import annotations

import sys
from json import loads
from pathlib import Path
from shutil import copyfile, copytree
from subprocess import run # noqa: S404
from typing import TypedDict, cast

from nodejs_wheel.executable import ROOT_DIR # pyright:ignore[reportMissingTypeStubs]

node_exe = Path(ROOT_DIR, ("node.exe" if sys.platform == "win32" else "bin/node"))

npm_script = Path(ROOT_DIR, "lib", "node_modules", "npm", "bin", "npm-cli.js")


# Remove when https://github.com/njzjz/nodejs-wheel/pull/24 is merged
def npm(cmd: list[str]):
_ = run([node_exe, npm_script, *cmd], check=True) # noqa: S603
from nodejs_wheel.executable import ( # pyright:ignore[reportMissingTypeStubs]
npm, # pyright:ignore[reportUnknownVariableType]
)


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


npm(["ci"])
npm(["run", "build:cli:dev"])
def run_npm(*args: str):
exit_code = npm(args)
if exit_code != 0:
raise Exception(f"the following npm command exited with {exit_code=}: {args}")


run_npm("ci")
run_npm("run", "build:cli:dev")

npm_package_dir = Path("packages/pyright")
pypi_package_dir = Path("basedpyright")
Expand Down

0 comments on commit cf89836

Please sign in to comment.