Skip to content

Commit 6e94419

Browse files
committed
feat(build): copy non-TS test assets into dist during build
Add scripts/copy-test-assets.js to copy non-TS assets from test/ to dist/test/. Invoke from build: tsc -> tsc && node scripts/copy-test-assets.js. Tooling-only change.
1 parent d560be2 commit 6e94419

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"scripts": {
1212
"test": "yarn build && tsc -p test/tsconfig.json && FASTIFY_AUTOLOAD_TYPESCRIPT=1 node --test --experimental-test-coverage 'dist/test/**/*.js'",
13-
"build": "tsc",
13+
"build": "tsc && node scripts/copy-test-assets.js",
1414
"watch": "tsc -w",
1515
"start": "fastify start -l info dist/src/app.js --options",
1616
"dev": "yarn run build && concurrently -k -p '[{name}]' -n TypeScript,App -c yellow.bold,cyan.bold yarn:watch yarn:dev:start",

scripts/copy-test-assets.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env node
2+
import { cp } from "fs/promises";
3+
import path from "path";
4+
5+
const src = path.resolve("test");
6+
const dest = path.resolve("dist", "test");
7+
8+
async function main() {
9+
try {
10+
// Copy everything under test to dist/test but skip TypeScript source files (.ts)
11+
await cp(src, dest, {
12+
recursive: true,
13+
filter: (srcPath) => {
14+
// Skip .ts files (keep .json, .html, .ics, etc.)
15+
if (srcPath.endsWith(".ts")) return false;
16+
return true;
17+
},
18+
});
19+
console.error("Copied test assets to", dest);
20+
} catch (err) {
21+
console.error("Failed to copy test assets:", err);
22+
process.exitCode = 1;
23+
}
24+
}
25+
26+
main();

0 commit comments

Comments
 (0)