From 159ef008de3ded735b4ba163cb1d802e19cd1382 Mon Sep 17 00:00:00 2001 From: powermaker450 Date: Wed, 21 Aug 2024 03:04:23 -0400 Subject: [PATCH] Fix crash when data.json doesn't exist --- package.json | 2 +- src/utils/functions.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f850977..ea60cfc 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "./dist/main.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "clean": "rm -rf ./dist ./persist", + "clean": "rm -rf ./dist", "build": "pnpm clean && tsc -p .", "start": "node ./dist/main.js", "clean-start": "pnpm build && pnpm start" diff --git a/src/utils/functions.ts b/src/utils/functions.ts index 17a7bc5..9346f7d 100644 --- a/src/utils/functions.ts +++ b/src/utils/functions.ts @@ -9,7 +9,7 @@ export function checkFile( const fullPath = dir + file; let final: ServerSideReview[]; - if (fs.existsSync(dir)) { + if (fs.existsSync(fullPath)) { const data = fs.readFileSync(fullPath, encoding); final = !data.toString().trim() ? [] : JSON.parse(data.toString());