Skip to content

Commit 1adf3b5

Browse files
natemoo-regithub-actions[bot]
authored andcommitted
[ci] format
1 parent c32ed0f commit 1adf3b5

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/test-utils.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,39 @@ import { fileURLToPath, pathToFileURL } from "node:url";
66
import { onTestFinished } from "vitest";
77

88
export interface Fixture {
9-
root: URL;
10-
resolve: (...segments: string[]) => URL;
11-
readFile: (file: PathLike) => Promise<string>;
12-
cleanup: () => Promise<void>;
9+
root: URL;
10+
resolve: (...segments: string[]) => URL;
11+
readFile: (file: PathLike) => Promise<string>;
12+
cleanup: () => Promise<void>;
1313
}
1414

1515
export async function createFixture(files: Record<string, string>): Promise<Fixture> {
16-
const root = new URL(`bsh-`, `file://${tmpdir()}/`);
17-
const path = await mkdtemp(fileURLToPath(root));
18-
const base = pathToFileURL(path + sep);
16+
const root = new URL(`bsh-`, `file://${tmpdir()}/`);
17+
const path = await mkdtemp(fileURLToPath(root));
18+
const base = pathToFileURL(path + sep);
1919

20-
for (const [name, content] of Object.entries(files)) {
21-
const url = new URL(name, base);
22-
const dir = new URL("./", url);
23-
await mkdir(dir, { recursive: true });
24-
if (name.endsWith(".json") && typeof content !== "string") {
25-
await writeFile(url, JSON.stringify(content, null, 2), "utf8");
26-
} else {
27-
await writeFile(url, content, "utf8");
28-
}
29-
}
20+
for (const [name, content] of Object.entries(files)) {
21+
const url = new URL(name, base);
22+
const dir = new URL("./", url);
23+
await mkdir(dir, { recursive: true });
24+
if (name.endsWith(".json") && typeof content !== "string") {
25+
await writeFile(url, JSON.stringify(content, null, 2), "utf8");
26+
} else {
27+
await writeFile(url, content, "utf8");
28+
}
29+
}
3030

31-
const cleanup = () => rm(path, { recursive: true, force: true });
32-
onTestFinished(cleanup);
31+
const cleanup = () => rm(path, { recursive: true, force: true });
32+
onTestFinished(cleanup);
3333

34-
const resolve = (...segments: string[]) => new URL(`./${segments.join("/")}`, base);
35-
const readFile = (file: PathLike) =>
36-
fsReadFile(new URL(`./${file}`, base), { encoding: "utf-8" });
34+
const resolve = (...segments: string[]) => new URL(`./${segments.join("/")}`, base);
35+
const readFile = (file: PathLike) =>
36+
fsReadFile(new URL(`./${file}`, base), { encoding: "utf-8" });
3737

38-
return {
39-
root: pathToFileURL(path),
40-
resolve,
41-
readFile,
42-
cleanup,
43-
};
38+
return {
39+
root: pathToFileURL(path),
40+
resolve,
41+
readFile,
42+
cleanup,
43+
};
4444
}

0 commit comments

Comments
 (0)