From 3c17e179584371933df0a63f0f9903062d241b52 Mon Sep 17 00:00:00 2001 From: Jack Stevenson Date: Tue, 8 Oct 2024 10:05:42 +1100 Subject: [PATCH] fix(type-safe-api): path undefined issue for particular node versions (#844) The fs.dirent class uses `parentPath` as the preferred member for the path of a file entry, however some node versions still use the now deprecated `path` member and `parentPath` is undefined, causing the generate script to fail to find templates. Address this by falling back to the `path` member. Fixes #838 --- .../scripts/type-safe-api/generators/generate-next.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/type-safe-api/scripts/type-safe-api/generators/generate-next.ts b/packages/type-safe-api/scripts/type-safe-api/generators/generate-next.ts index 34c7c1a2a..16852d4e5 100755 --- a/packages/type-safe-api/scripts/type-safe-api/generators/generate-next.ts +++ b/packages/type-safe-api/scripts/type-safe-api/generators/generate-next.ts @@ -649,7 +649,7 @@ export default async (argv: string[], rootScriptDir: string) => { const templates = args.templateDirs.flatMap(t => fs.readdirSync(resolveTemplateDir(rootScriptDir, t), { recursive: true, withFileTypes: true - }).filter(f => f.isFile() && f.name.endsWith('.ejs')).map(f => path.join(f.parentPath, f.name))); + }).filter(f => f.isFile() && f.name.endsWith('.ejs')).map(f => path.join(f.parentPath ?? f.path, f.name))); // Render the templates with the data from the spec const renderedFiles = templates.map((template) => {