Skip to content

Commit 2feee9b

Browse files
authored
chore: Use symlinks for static assets served. (#2003)
1 parent a5fcd0f commit 2feee9b

File tree

4 files changed

+3855
-3825
lines changed

4 files changed

+3855
-3825
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"jsx": "react-jsx",
4141
"jsxImportSource": "@commontools/html",
4242
"types": [
43-
"./packages/static/assets/types/jsx.d.ts"
43+
"./packages/html/src/jsx.d.ts"
4444
],
4545
"lib": [
4646
"deno.ns",

packages/deno-web-test/utils.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as path from "@std/path";
22
import { Manifest } from "./manifest.ts";
33
import { Summary, TestFileResults } from "./interface.ts";
4-
import { copy } from "@std/fs";
54
import { build } from "@commontools/felt";
65

76
export const tsToJs = (path: string): string => path.replace(/\.ts$/, ".js");
@@ -65,3 +64,33 @@ export function summarize(results: TestFileResults[]): Summary {
6564
}
6665
return { passed, duration, failed };
6766
}
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

Comments
 (0)