From ed044cb45ed5f75072dfdae3daff5d715a342178 Mon Sep 17 00:00:00 2001 From: yorrd <kai@adornis.de> Date: Thu, 24 Apr 2025 14:49:11 +0000 Subject: [PATCH] chore: fix dont override settings.json --- modules/esbuild/src/plugins/paraglide-plugin.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/esbuild/src/plugins/paraglide-plugin.ts b/modules/esbuild/src/plugins/paraglide-plugin.ts index d6933c7ba6..7965c8a66f 100644 --- a/modules/esbuild/src/plugins/paraglide-plugin.ts +++ b/modules/esbuild/src/plugins/paraglide-plugin.ts @@ -1,4 +1,4 @@ -import { access, constants, mkdir, writeFile } from 'fs/promises'; +import { access, constants, mkdir, stat, writeFile } from 'fs/promises'; import { join } from 'path'; const createInlangConfig = async (localizationDir: string) => { @@ -48,15 +48,21 @@ const createMessageFiles = async (localizationDir: string) => { export const paraglidePlugin = async ({ localizationDir }: { localizationDir: string }) => { try { - // Create localization and settings if they don't exist - await createInlangConfig(localizationDir); - await createMessageFiles(localizationDir); - // Verify only config files exist const projectDir = join(localizationDir, 'project.inlang'); const messagesDir = join(localizationDir, 'messages'); const settingsPath = join(projectDir, 'settings.json'); + // Create localization and settings if they don't exist + if ( + !(await stat(settingsPath) + .then(() => true) + .catch(() => false)) + ) { + await createInlangConfig(localizationDir); + await createMessageFiles(localizationDir); + } + // Check if required directories and settings exist await Promise.all([ access(localizationDir, constants.R_OK), -- GitLab