From c9abc6dc5c867e1a6d0cfb6746f846770a125055 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Sun, 17 Nov 2024 23:05:41 +0100 Subject: [PATCH] Fix crawl async --- src/bin/tools/crawlAsync.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bin/tools/crawlAsync.ts b/src/bin/tools/crawlAsync.ts index e1fda91b..eebd3d29 100644 --- a/src/bin/tools/crawlAsync.ts +++ b/src/bin/tools/crawlAsync.ts @@ -6,19 +6,19 @@ import { assert, type Equals } from "tsafe/assert"; export async function crawlAsync(params: { dirPath: string; returnedPathsType: "absolute" | "relative to dirPath"; - onFileFound: (filePath: string) => void; + onFileFound: (filePath: string) => Promise; }) { const { dirPath, returnedPathsType, onFileFound } = params; await crawlAsyncRec({ dirPath, - onFileFound: ({ filePath }) => { + onFileFound: async ({ filePath }) => { switch (returnedPathsType) { case "absolute": - onFileFound(filePath); + await onFileFound(filePath); return; case "relative to dirPath": - onFileFound(pathRelative(dirPath, filePath)); + await onFileFound(pathRelative(dirPath, filePath)); return; } assert>(); @@ -28,7 +28,7 @@ export async function crawlAsync(params: { async function crawlAsyncRec(params: { dirPath: string; - onFileFound: (params: { filePath: string }) => void; + onFileFound: (params: { filePath: string }) => Promise; }) { const { dirPath, onFileFound } = params; @@ -45,7 +45,7 @@ async function crawlAsyncRec(params: { return; } - onFileFound({ filePath: fileOrDirPath }); + await onFileFound({ filePath: fileOrDirPath }); }) ); }