fix: replace import.meta.url with process.cwd() in testkit.ts
import.meta.url is undefined when esbuild bundles to CJS format (format: 'cjs' in build.ts). fileURLToPath(undefined) throws ERR_INVALID_ARG_TYPE which crashed the production server on startup. Fix: drop the _dirname derivation entirely and resolve TIMMY_TEST_PLAN.md relative to process.cwd(), which is always the workspace root in both: - dev: tsx runs from workspace root - production: pnpm --filter ... run start runs from workspace root Also removes the now-unused 'dirname' and 'fileURLToPath' imports. Verified: rebuilt dist/index.cjs — 0 import.meta.url references remain. GET /api/testkit/plan returns HTTP 200 from the production bundle.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { Router, type Request, type Response } from "express";
|
||||
import { readFileSync } from "fs";
|
||||
import { resolve, dirname } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { resolve } from "path";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -1105,8 +1104,7 @@ if [[ "\$FAIL" -gt 0 ]]; then exit 1; fi
|
||||
* Returns TIMMY_TEST_PLAN.md verbatim as text/markdown.
|
||||
* Path resolves from the project root regardless of cwd.
|
||||
*/
|
||||
const _dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const PLAN_PATH = resolve(_dirname, "../../../../TIMMY_TEST_PLAN.md");
|
||||
const PLAN_PATH = resolve(process.cwd(), "TIMMY_TEST_PLAN.md");
|
||||
|
||||
router.get("/testkit/plan", (_req: Request, res: Response) => {
|
||||
let content: string;
|
||||
|
||||
Reference in New Issue
Block a user