Skip to content

Commit 74204e6

Browse files
committed
refactor(scripts): update test script to use modern deno apis
1 parent 3e12d99 commit 74204e6

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

scripts/update_tests.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
#!/usr/bin/env -S deno run --allow-read --allow-write
2-
import { walk } from "jsr:@std/fs/walk";
2+
import { expandGlob } from "jsr:@std/fs";
3+
import { fromFileUrl } from "jsr:@std/path";
34

4-
import init, { format } from "../build/dart_fmt.js";
5+
import { format } from "../build/dart_fmt_esm.js";
56

6-
await init();
7+
const test_root = fromFileUrl(new URL(import.meta.resolve("../test_data")));
78

8-
const test_root = new URL(import.meta.resolve("../test_data"));
9-
10-
for await (const entry of walk(test_root, {
11-
includeDirs: false,
12-
exts: ["unit"],
13-
})) {
9+
for await (const entry of expandGlob("**/*.unit", { root: test_root, includeDirs: false })) {
1410
if (entry.name.startsWith(".")) {
1511
continue;
1612
}
1713

1814
const expect_path = entry.path + ".snap";
19-
const input = Deno.readTextFileSync(entry.path);
15+
const input = await Deno.readTextFile(entry.path);
2016

2117
const actual = format(input, entry.path);
22-
Deno.writeTextFileSync(expect_path, actual);
18+
await Deno.writeTextFile(expect_path, actual);
2319
}
2420
console.log("done");

0 commit comments

Comments
 (0)