mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 20:09:04 +00:00
* Move ReadFile and WriteFile to separate file * Use libuv for Bun.write() * Update windows_event_loop.zig * build * Get bun-write tests to pass. Implement Bun.write with two files. * UPdate * Update * Update failing test list * update * More * More * More * More * Mark the rest * ok * oops * Update bun-write.test.js * Update blob.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Dave Caruso <me@paperdave.net> Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
42 lines
1019 B
TypeScript
42 lines
1019 B
TypeScript
// https://github.com/oven-sh/bun/issues/3216
|
|
import { test, expect } from "bun:test";
|
|
import { tmpdir } from "os";
|
|
import { mkdtempSync, writeFileSync } from "fs";
|
|
import { join } from "path";
|
|
import { bunEnv, bunExe } from "harness";
|
|
|
|
test("runtime directory caching gets invalidated", () => {
|
|
const tmp = mkdtempSync(join(tmpdir(), "bun-test-"));
|
|
writeFileSync(
|
|
join(tmp, "index.ts"),
|
|
`const file = \`\${import.meta.dir}/temp.mjs\`;
|
|
|
|
import { existsSync, unlinkSync, writeFileSync } from "fs";
|
|
|
|
if (existsSync(file)) {
|
|
console.log("temp.mjs cannot exist before running this script");
|
|
unlinkSync(file);
|
|
process.exit(2);
|
|
}
|
|
|
|
writeFileSync(file, "export default 1;");
|
|
|
|
try {
|
|
const module = await import(file);
|
|
console.log(module.default);
|
|
} finally {
|
|
unlinkSync(file);
|
|
}
|
|
`,
|
|
);
|
|
|
|
const result = Bun.spawnSync({
|
|
cmd: [bunExe(), "run", join(tmp, "index.ts")],
|
|
cwd: tmp,
|
|
env: bunEnv,
|
|
});
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
expect(result.stdout.toString("utf-8")).toBe("1\n");
|
|
});
|