|
1 | 1 | import * as path from "@std/path"; |
2 | 2 | import { Manifest } from "./manifest.ts"; |
3 | 3 | import { Summary, TestFileResults } from "./interface.ts"; |
4 | | -import { copy } from "@std/fs"; |
5 | 4 | import { build } from "@commontools/felt"; |
6 | 5 |
|
7 | 6 | export const tsToJs = (path: string): string => path.replace(/\.ts$/, ".js"); |
@@ -65,3 +64,33 @@ export function summarize(results: TestFileResults[]): Summary { |
65 | 64 | } |
66 | 65 | return { passed, duration, failed }; |
67 | 66 | } |
| 67 | + |
| 68 | +// Use this instead of `@std/fs#copy`, because we want to copy resolved |
| 69 | +// symlinks, not the symlinks themselves. |
| 70 | +async function copy(src: string, dest: string): Promise<void> { |
| 71 | + const stat = await Deno.lstat(src); |
| 72 | + |
| 73 | + if (stat.isSymlink) { |
| 74 | + const realPath = await Deno.realPath(src); |
| 75 | + const realStat = await Deno.stat(realPath); |
| 76 | + if (realStat.isDirectory) { |
| 77 | + await copyDir(realPath, dest); |
| 78 | + } else { |
| 79 | + await Deno.copyFile(realPath, dest); |
| 80 | + } |
| 81 | + } else if (stat.isDirectory) { |
| 82 | + await copyDir(src, dest); |
| 83 | + } else { |
| 84 | + await Deno.copyFile(src, dest); |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +async function copyDir(src: string, dest: string): Promise<void> { |
| 89 | + await Deno.mkdir(dest, { recursive: true }); |
| 90 | + |
| 91 | + for await (const entry of Deno.readDir(src)) { |
| 92 | + const srcPath = path.join(src, entry.name); |
| 93 | + const destPath = path.join(dest, entry.name); |
| 94 | + await copy(srcPath, destPath); |
| 95 | + } |
| 96 | +} |
0 commit comments