From 8b4ca5d7bc033c9ec1bb45e2d9eed13fbfdcbe5d Mon Sep 17 00:00:00 2001 From: Ravinou Date: Fri, 28 Mar 2025 17:58:22 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=9A=A1=20create=20repo.json=20if?= =?UTF-8?q?=20not=20exist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helpers/functions/fileHelpers.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/helpers/functions/fileHelpers.ts b/helpers/functions/fileHelpers.ts index 15eb0bd..16f148f 100644 --- a/helpers/functions/fileHelpers.ts +++ b/helpers/functions/fileHelpers.ts @@ -28,6 +28,13 @@ export const updateUsersList = async (usersList: BorgWarehouseUser[]): Promise => { + try { + await fs.access(repoFilePath); + } catch { + console.log('repo.json not found, creating a new one.'); + await fs.writeFile(repoFilePath, JSON.stringify([])); + } + try { const fileContent = await fs.readFile(repoFilePath, 'utf8'); return JSON.parse(fileContent) || [];