mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
Use absolute paths more
This commit is contained in:
@@ -3,11 +3,12 @@ import { mkdtempSync, realpathSync, rmSync } from "fs";
|
||||
import { bunEnv, bunExe } from "harness";
|
||||
import { tmpdir } from "os";
|
||||
import { join } from "path";
|
||||
import { tmpdirSync } from "./dummy.registry";
|
||||
|
||||
let package_dir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
package_dir = mkdtempSync(join(realpathSync(tmpdir()), "bun-install-path"));
|
||||
package_dir = tmpdirSync("bun-install-path");
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* PACKAGE_DIR_TO_USE=(realpath .) bun test/cli/install/dummy.registry.ts
|
||||
*/
|
||||
import { file, Server } from "bun";
|
||||
import { mkdtempSync, realpathSync } from "fs";
|
||||
|
||||
let expect: typeof import("bun:test")["expect"];
|
||||
|
||||
@@ -11,6 +12,10 @@ import { mkdtemp, readdir, realpath, rm, writeFile } from "fs/promises";
|
||||
import { tmpdir } from "os";
|
||||
import { basename, join } from "path";
|
||||
|
||||
export function tmpdirSync(pattern: string) {
|
||||
return mkdtempSync(join(realpathSync(tmpdir()), pattern));
|
||||
}
|
||||
|
||||
type Handler = (req: Request) => Response | Promise<Response>;
|
||||
type Pkg = {
|
||||
name: string;
|
||||
@@ -94,14 +99,13 @@ export function dummyAfterAll() {
|
||||
server.stop();
|
||||
}
|
||||
|
||||
let packageDirGetter: () => Promise<string> = async () => {
|
||||
return await mkdtemp(join(await realpath(tmpdir()), "bun-install-test-" + testCounter++ + "--"));
|
||||
let packageDirGetter: () => string = () => {
|
||||
return tmpdirSync("bun-install-test-" + testCounter++ + "--");
|
||||
};
|
||||
export async function dummyBeforeEach() {
|
||||
resetHandler();
|
||||
requested = 0;
|
||||
package_dir = await packageDirGetter();
|
||||
|
||||
package_dir = packageDirGetter();
|
||||
await writeFile(
|
||||
join(package_dir, "bunfig.toml"),
|
||||
`
|
||||
@@ -129,7 +133,7 @@ if (Bun.main === import.meta.path) {
|
||||
};
|
||||
};
|
||||
if (process.env.PACKAGE_DIR_TO_USE) {
|
||||
packageDirGetter = () => Promise.resolve(process.env.PACKAGE_DIR_TO_USE!);
|
||||
packageDirGetter = () => process.env.PACKAGE_DIR_TO_USE!;
|
||||
}
|
||||
|
||||
await dummyBeforeAll();
|
||||
|
||||
Reference in New Issue
Block a user