Skip to content

Commit

Permalink
rewrite the npm function in pdm_build.py because it was failing and…
Browse files Browse the repository at this point in the history
… idk why
  • Loading branch information
DetachHead committed Apr 25, 2024
1 parent 711a0bf commit 9435e4a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pdm_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
from json import loads
from pathlib import Path
from shutil import copyfile, copytree
from typing import List, TypedDict, cast
from subprocess import run # noqa: S404
from typing import TypedDict, cast

from nodejs_wheel import executable
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 run(cmd: List[str]):
old_sys_argv = sys.argv
sys.argv = [old_sys_argv[0]] + cmd
try:
executable.npm()
finally:
sys.argv = old_sys_argv
def npm(cmd: list[str]):
_ = run([node_exe, npm_script, *cmd], check=True) # noqa: S603


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


run(["ci"])
run(["run", "build:cli:dev"])
npm(["ci"])
npm(["run", "build:cli:dev"])

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

0 comments on commit 9435e4a

Please sign in to comment.