mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
20 lines
634 B
TypeScript
20 lines
634 B
TypeScript
import { $ } from "bun";
|
|
import { expect, test } from "bun:test";
|
|
import { tempDirWithFiles } from "harness";
|
|
import { rmSync } from "node:fs";
|
|
import { join } from "path";
|
|
|
|
test("$ is lazy", async () => {
|
|
const base = tempDirWithFiles("bun-lazy-test", {
|
|
"bun-lazy": "789",
|
|
});
|
|
const path = join(base, "bun-lazy");
|
|
rmSync(path, { force: true, recursive: true });
|
|
const pending = $`echo 123 > ${path}`;
|
|
expect(async () => await Bun.file(path).text()).toThrow();
|
|
await Bun.write(path, "456");
|
|
expect(await Bun.file(path).text()).toBe("456");
|
|
await pending;
|
|
expect(await Bun.file(path).text()).toBe("123\n");
|
|
});
|