This commit is contained in:
Ashcon Partovi
2024-05-31 12:11:10 -07:00
parent 0329469e2a
commit 942f64ddd1
2 changed files with 15 additions and 11 deletions

View File

@@ -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();
}

View File

@@ -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<void>(done => {