Skip to content

Commit

Permalink
fix(type-safe-api): path undefined issue for particular node versions (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
cogwirrel authored Oct 7, 2024
1 parent 39ad2da commit 3c17e17
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 3c17e17

Please sign in to comment.