From 6514eb520901e4f9ad833ce073ef5b2a0f36919e Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 21 Oct 2022 13:19:44 -0400 Subject: [PATCH] Make the assets/themes folder if it doesn't exist - Also only run clearThemes if the folder exists Co-Authored-By: Mikayla Maki --- styles/src/buildThemes.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/styles/src/buildThemes.ts b/styles/src/buildThemes.ts index d0d014e71e..32749a7aaa 100644 --- a/styles/src/buildThemes.ts +++ b/styles/src/buildThemes.ts @@ -17,11 +17,15 @@ const tempDirectory = fs.mkdtempSync(path.join(tmpdir(), "build-themes")); // Clear existing themes function clearThemes(themeDirectory: string) { - for (const file of fs.readdirSync(themeDirectory)) { - if (file.endsWith(".json")) { - const name = file.replace(/\.json$/, ""); - if (!colorSchemes.find((colorScheme) => colorScheme.name === name)) { - fs.unlinkSync(path.join(themeDirectory, file)); + if (!fs.existsSync(themeDirectory)) { + fs.mkdirSync(themeDirectory, { recursive: true }); + } else { + for (const file of fs.readdirSync(themeDirectory)) { + if (file.endsWith(".json")) { + const name = file.replace(/\.json$/, ""); + if (!colorSchemes.find((colorScheme) => colorScheme.name === name)) { + fs.unlinkSync(path.join(themeDirectory, file)); + } } } }