Skip to content

Commit 90c06b0

Browse files
committed
Resolve npm through the shell for Windows compatibility
The UI license enumeration invoked npm by bare name via subprocess, which fails on Windows (npm is npm.cmd there — WinError 2 in the Windows UI-archive packaging step). Resolve it through the shell, which handles platform shims everywhere; the command is a constant string. Signed-off-by: Martin Vogel <martin.vogel@datadice.io>
1 parent 53ca844 commit 90c06b0

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

scripts/gen-ui-licenses.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ def declared_license(pkg_dir):
6767

6868
def main():
6969
ui_dir = sys.argv[1]
70+
# shell=True so the npm shim resolves on every platform (npm.cmd on
71+
# Windows is not found by bare-name exec). Constant command, no injection.
7072
ls = subprocess.run(
71-
["npm", "ls", "--omit=dev", "--all", "--json"],
72-
cwd=ui_dir, capture_output=True, text=True, check=False,
73+
"npm ls --omit=dev --all --json",
74+
shell=True, cwd=ui_dir, capture_output=True, text=True, check=False,
7375
)
7476
tree = json.loads(ls.stdout or "{}")
7577
pkgs = set()

scripts/license-gate-check-npm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ def main():
6969
ignored_pkgs = set(policy.get("ignored_npm_packages", []))
7070
skip_tokens = {"and", "or", "with", ""}
7171

72-
ls = subprocess.run(["npm", "ls", "--omit=dev", "--all", "--json"],
73-
cwd=ui_dir, capture_output=True, text=True, check=False)
72+
# shell=True so the npm shim resolves on every platform (npm.cmd on
73+
# Windows is not found by bare-name exec). Constant command, no injection.
74+
ls = subprocess.run("npm ls --omit=dev --all --json",
75+
shell=True, cwd=ui_dir, capture_output=True, text=True, check=False)
7476
tree = json.loads(ls.stdout or "{}")
7577
pkgs = {}
7678
collect(ui_dir, tree.get("dependencies"), pkgs)

0 commit comments

Comments
 (0)