Skip to content

Commit 4bed1dd

Browse files
authored
refactor asynchronous code (#10018)
1 parent ed961a0 commit 4bed1dd

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

packages/wrangler/e2e/helpers/setup.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ export async function seed(
1414
files: Record<string, string | Uint8Array>
1515
) {
1616
// TODO(someday): allow copying/symlinking file/directory paths in seed? like "path`${__dirname}/../fixture`"?
17-
for (const [name, contents] of Object.entries(files)) {
18-
const filePath = path.resolve(root, name);
19-
await mkdir(path.dirname(filePath), { recursive: true });
20-
await writeFile(filePath, contents);
21-
}
17+
await Promise.all(
18+
Object.entries(files).map(async ([name, contents]) => {
19+
const filePath = path.resolve(root, name);
20+
await mkdir(path.dirname(filePath), { recursive: true });
21+
await writeFile(filePath, contents);
22+
})
23+
);
2224
}
2325

2426
// Removes the given files from the `root` directory on the file system.
2527
export async function removeFiles(root: string, files: string[]) {
26-
for (const name of files) {
27-
const filePath = path.resolve(root, name);
28-
if (filePath) {
29-
await rm(filePath);
30-
}
31-
}
28+
await Promise.all(
29+
files.map(async (name) => {
30+
const filePath = path.resolve(root, name);
31+
await rm(filePath, { force: true });
32+
})
33+
);
3234
}

0 commit comments

Comments
 (0)