Skip to content

Commit 68e7085

Browse files
chore: improve init tests (#3590)
1 parent 5a220c6 commit 68e7085

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

deno.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/fresh/deno.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@std/semver": "jsr:@std/semver@^1.0.6",
2626
"@std/uuid": "jsr:@std/uuid@^1.0.9",
2727
"@types/node": "npm:@types/node@^24.2.1",
28+
"esbuild-wasm": "npm:esbuild-wasm@^0.25.11",
2829
"preact": "npm:preact@^10.27.2",
2930
"preact-render-to-string": "npm:preact-render-to-string@^6.6.3"
3031
}

packages/init/src/init_test.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ async function patchProject(dir: string): Promise<void> {
6262
}
6363
}
6464

65-
const ignore = /[/\\]+(.|[^/\\]+_test\..*|tests[^/\\])/;
65+
const ignore = (entry: Deno.DirEntry, _full: string) => {
66+
return /^(\.|tmp_)/.test(entry.name) ||
67+
/_test\.[tj]sx?$/.test(entry.name) ||
68+
entry.name === "tests" || entry.name === "test";
69+
};
6670

6771
await copyRecursive(
6872
path.join(import.meta.dirname!, "..", "..", "fresh"),
@@ -77,6 +81,7 @@ async function patchProject(dir: string): Promise<void> {
7781
);
7882

7983
json.workspace = ["./_linked/*"];
84+
json.exclude = [...json.exclude ?? [], "**/_linked/*"];
8085

8186
// assert with this stricter rule, before adding it to initialized projects
8287
json.lint.rules.include = ["verbatim-module-syntax"];
@@ -101,13 +106,15 @@ async function patchProject(dir: string): Promise<void> {
101106
async function copyRecursive(
102107
from: string,
103108
to: string,
104-
ignore?: RegExp,
109+
ignore?: (entry: Deno.DirEntry, full: string) => boolean,
105110
): Promise<void> {
106111
for await (const entry of Deno.readDir(from)) {
107112
const source = path.join(from, entry.name);
108113
const target = path.join(to, entry.name);
109114

110-
if (ignore && ignore.test(source)) continue;
115+
if (ignore && ignore(entry, source)) {
116+
continue;
117+
}
111118

112119
if (entry.isFile) {
113120
try {
@@ -119,7 +126,7 @@ async function copyRecursive(
119126
}
120127
await Deno.copyFile(source, target);
121128
} else if (entry.isDirectory) {
122-
await copyRecursive(source, target);
129+
await copyRecursive(source, target, ignore);
123130
}
124131
}
125132
}

0 commit comments

Comments
 (0)