(dir: string, files: Record<string, string>)
| 204 | } |
| 205 | |
| 206 | export async function writeFiles(dir: string, files: Record<string, string>) { |
| 207 | const entries = Object.entries(files); |
| 208 | await Promise.all(entries.map(async (entry) => { |
| 209 | const [pathname, content] = entry; |
| 210 | const fullPath = path.join(dir, pathname); |
| 211 | try { |
| 212 | await Deno.mkdir(path.dirname(fullPath), { recursive: true }); |
| 213 | await Deno.writeTextFile(fullPath, content); |
| 214 | } catch (err) { |
| 215 | if (!(err instanceof Deno.errors.AlreadyExists)) { |
| 216 | throw err; |
| 217 | } |
| 218 | } |
| 219 | })); |
| 220 | } |
no test coverage detected