Skip to content

Commit

Permalink
Fix: Await file promises when reading controller user templates
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardvdj committed Dec 15, 2024
1 parent 7999f1c commit cb7d1d6
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/lib/controller-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,18 @@ export class ControllerManager {
cwd: templateDirUser,
absolute: true,
});
let parsedTemplatesUser: ControllerTemplate[] = filesUser
.filter((f: string) => fs.lstatSync(f).isFile())
.map(async (f: string) =>
Object.assign(
{ mappingId: f.split(path.sep).slice(-2)[0] },
genericParser.parse(await fs.readFile(f, "utf-8")),
),
let parsedTemplatesUser: ControllerTemplate[] = (
await Promise.all(
filesUser
.filter((f: string) => fs.lstatSync(f).isFile())
.map(async (f: string) =>
Object.assign(
{ mappingId: f.split(path.sep).slice(-2)[0] },
genericParser.parse(await fs.readFile(f, "utf-8")),
),
),
)
)
.filter(
(x: any) =>
!!x["controller_mappings"] &&
Expand Down

0 comments on commit cb7d1d6

Please sign in to comment.