From ba4641dd1b23ea830d733da01319072bef4ca80e Mon Sep 17 00:00:00 2001 From: Lajos Meszaros Date: Mon, 20 May 2024 23:04:54 +0200 Subject: [PATCH] perf(ArxMap): only create directories for exporting once per file --- src/ArxMap.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ArxMap.ts b/src/ArxMap.ts index b06f06a5..fcc5b324 100644 --- a/src/ArxMap.ts +++ b/src/ArxMap.ts @@ -43,7 +43,7 @@ import { Zone } from '@src/Zone.js' import { Zones } from '@src/Zones.js' import { compile } from '@src/compile.js' import { MapFinalizedError, MapNotFinalizedError } from '@src/errors.js' -import { times } from '@src/faux-ramda.js' +import { times, uniq } from '@src/faux-ramda.js' import { getGeneratorPackageJSON, latin9ToLatin1 } from '@src/helpers.js' import { OriginalLevel } from '@src/types.js' @@ -477,8 +477,9 @@ export class ArxMap { ...Object.values(files).map((filename) => filename.replace(/\.json$/, '')), ] - for (const filename of pathsOfTheFiles) { - await fs.mkdir(path.dirname(filename), { recursive: true }) + const dirnames = uniq(pathsOfTheFiles.map(path.dirname.bind(path))) + for (const dirname of dirnames) { + await fs.mkdir(dirname, { recursive: true }) } // ------------------------