Skip to content

Commit

Permalink
Fix: Await file promises when reading controller user templates (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardvdj authored Dec 23, 2024
1 parent 367dc9d commit 40d78c7
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 40d78c7

Please sign in to comment.