From de40285e2138d8166ed35d55de0872bd7888ef88 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 23 Sep 2024 15:37:58 +0500 Subject: [PATCH] core: create languages directory if it doesn't exist --- packages/core/scripts/prebuild.mjs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/core/scripts/prebuild.mjs b/packages/core/scripts/prebuild.mjs index e3391af57..fb6ccb58f 100644 --- a/packages/core/scripts/prebuild.mjs +++ b/packages/core/scripts/prebuild.mjs @@ -19,7 +19,7 @@ along with this program. If not, see . import "isomorphic-fetch"; import path from "path"; -import fs from "fs/promises"; +import fs, { mkdir } from "fs/promises"; import { langen } from "../../editor/scripts/langen.mjs"; import { fileURLToPath } from "url"; @@ -30,15 +30,14 @@ const ROOT_DIR = path.resolve(path.join(__dirname, "..")); const { languageIndex } = await langen(ROOT_DIR); if (!languageIndex) throw new Error("No language index found."); -await fs.writeFile( - path.join( - ROOT_DIR, - "src", - "utils", - "templates", - "html", - "languages", - "index.ts" - ), - languageIndex +const languagesDir = path.join( + ROOT_DIR, + "src", + "utils", + "templates", + "html", + "languages" ); +await mkdir(languagesDir, { recursive: true }); + +await fs.writeFile(path.join(languagesDir, "index.ts"), languageIndex);