diff --git a/packages/bun-internal-test/src/runner.node.mjs b/packages/bun-internal-test/src/runner.node.mjs index cfd2f7f7dc..ee38701aac 100644 --- a/packages/bun-internal-test/src/runner.node.mjs +++ b/packages/bun-internal-test/src/runner.node.mjs @@ -13,8 +13,9 @@ import { writeFileSync, } from "node:fs"; import { readdirSync } from "node:fs"; -import { tmpdir, cpus, hostname } from "node:os"; +import { tmpdir, hostname } from "node:os"; import { join, resolve, basename, dirname, relative } from "node:path"; +import { normalize as normalizeWindows } from "node:path/win32"; import { inspect } from "node:util"; import readline from "node:readline/promises"; @@ -394,19 +395,15 @@ function getTmpdir() { return "/tmp"; } } - for (const key of ["TMPDIR", "TEMP", "TEMPDIR", "TMP", "RUNNER_TEMP"]) { - const tmpdir = process.env[key]; - if (!tmpdir || !existsSync(tmpdir)) { - continue; - } - if (isWindows) { + if (isWindows) { + for (const key of ["TMPDIR", "TEMP", "TEMPDIR", "TMP"]) { + const tmpdir = process.env[key] || ""; if (!/^\/[a-zA-Z]\//.test(tmpdir)) { continue; } - const driveLetter = tmpdir[1].toUpperCase(); - return path.win32.normalize(`${driveLetter}:${tmpdir.substring(2)}`); + const driveLetter = tmpdir[1]; + return normalizeWindows(`${driveLetter.toUpperCase()}:${tmpdir.substring(2)}`); } - return tmpdir; } return tmpdir(); } diff --git a/test/cli/install/registry/bun-install-registry.test.ts b/test/cli/install/registry/bun-install-registry.test.ts index eee032f5c8..8d5e7b75e9 100644 --- a/test/cli/install/registry/bun-install-registry.test.ts +++ b/test/cli/install/registry/bun-install-registry.test.ts @@ -1,6 +1,7 @@ import { file, spawn, write } from "bun"; import { bunExe, + nodeExe, bunEnv as env, isLinux, isWindows, @@ -36,7 +37,13 @@ beforeAll(async () => { verdaccioServer = fork( require.resolve("verdaccio/bin/verdaccio"), ["-c", join(import.meta.dir, "verdaccio.yaml"), "-l", `${port}`], - { silent: true, execPath: bunExe() }, + { + silent: true, + // Prefer using Node.js if it's available, + // since the debug version of Bun may be slower + // and may have other bugs that make it harder to debug. + execPath: nodeExe() || bunExe(), + }, ); await new Promise(done => {