|
1 | 1 | import * as child_process from "node:child_process"; |
2 | 2 | import * as fs from "node:fs/promises"; |
3 | 3 | import * as path from "node:path"; |
4 | | -import { execPath } from "node:process"; |
5 | 4 | import { bsc_exe, rescript_legacy_exe } from "#cli/bins"; |
6 | 5 |
|
7 | | -const npmBin = path.join(path.dirname(execPath), "npm"); |
8 | | - |
9 | 6 | /** |
10 | 7 | * @typedef {{ |
11 | 8 | * throwOnFail?: boolean, |
@@ -53,14 +50,18 @@ export function setup(cwd = process.cwd()) { |
53 | 50 | async function exec(command, args = [], options = {}) { |
54 | 51 | const { throwOnFail = options.stdio === "inherit" } = options; |
55 | 52 |
|
| 53 | + if (process.env.CI) { |
| 54 | + console.log("[exec] PATH =", options.env?.PATH ?? process.env.PATH); |
| 55 | + } |
| 56 | + |
56 | 57 | const stdoutChunks = []; |
57 | 58 | const stderrChunks = []; |
58 | 59 |
|
59 | 60 | const subprocess = child_process.spawn(command, args, { |
60 | 61 | cwd, |
61 | 62 | shell: process.platform === "win32", |
62 | 63 | stdio: ["ignore", "pipe", "pipe"], |
63 | | - env: { ...process.env, ...options.env }, |
| 64 | + env: options.env ? { ...process.env, ...options.env } : process.env, |
64 | 65 | ...options, |
65 | 66 | }); |
66 | 67 |
|
@@ -255,7 +256,7 @@ export function setup(cwd = process.cwd()) { |
255 | 256 | * @return {Promise<ExecResult>} |
256 | 257 | */ |
257 | 258 | npm(args = [], options = {}) { |
258 | | - return exec(npmBin, args, options); |
| 259 | + return exec("npm", args, options); |
259 | 260 | }, |
260 | 261 | }; |
261 | 262 | } |
0 commit comments