( from: string, to: string, ignore?: (entry: Deno.DirEntry, full: string) => boolean, )
| 104 | } |
| 105 | |
| 106 | async function copyRecursive( |
| 107 | from: string, |
| 108 | to: string, |
| 109 | ignore?: (entry: Deno.DirEntry, full: string) => boolean, |
| 110 | ): Promise<void> { |
| 111 | for await (const entry of Deno.readDir(from)) { |
| 112 | const source = path.join(from, entry.name); |
| 113 | const target = path.join(to, entry.name); |
| 114 | |
| 115 | if (ignore && ignore(entry, source)) { |
| 116 | continue; |
| 117 | } |
| 118 | |
| 119 | if (entry.isFile) { |
| 120 | try { |
| 121 | await Deno.mkdir(to, { recursive: true }); |
| 122 | } catch (err) { |
| 123 | if (!(err instanceof Deno.errors.AlreadyExists)) { |
| 124 | throw err; |
| 125 | } |
| 126 | } |
| 127 | await Deno.copyFile(source, target); |
| 128 | } else if (entry.isDirectory) { |
| 129 | await copyRecursive(source, target, ignore); |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | async function expectProjectFile(dir: string, pathname: string) { |
| 135 | const filePath = path.join(dir, ...pathname.split("/").filter(Boolean)); |
no test coverage detected