QA: accept nodejs as Node runtime

This commit is contained in:
Gustavo Madeira Santana
2026-04-16 02:39:52 -04:00
parent 51b5d16faf
commit 8ecb6bbb12
2 changed files with 19 additions and 1 deletions

View File

@@ -12,6 +12,19 @@ describe("resolveQaNodeExecPath", () => {
).resolves.toBe("/opt/homebrew/bin/node");
});
it("reuses nodejs as a valid current Node executable", async () => {
await expect(
resolveQaNodeExecPath({
execPath: "/usr/bin/nodejs",
platform: "linux",
versions: { ...process.versions, bun: undefined },
execFileImpl: async () => {
throw new Error("should not search PATH");
},
}),
).resolves.toBe("/usr/bin/nodejs");
});
it("resolves node from PATH when the parent runtime is bun", async () => {
await expect(
resolveQaNodeExecPath({

View File

@@ -16,7 +16,12 @@ const execFileAsync = promisify(execFile) as unknown as ExecFileAsync;
function isNodeExecPath(execPath: string, platform: NodeJS.Platform): boolean {
const pathModule = platform === "win32" ? path.win32 : path.posix;
const basename = pathModule.basename(execPath).toLowerCase();
return basename === "node" || basename === "node.exe";
return (
basename === "node" ||
basename === "node.exe" ||
basename === "nodejs" ||
basename === "nodejs.exe"
);
}
export async function resolveQaNodeExecPath(params?: {