Fix crash when data.json doesn't exist
This commit is contained in:
parent
ed9a4cb146
commit
159ef008de
|
@ -5,7 +5,7 @@
|
||||||
"main": "./dist/main.js",
|
"main": "./dist/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"clean": "rm -rf ./dist ./persist",
|
"clean": "rm -rf ./dist",
|
||||||
"build": "pnpm clean && tsc -p .",
|
"build": "pnpm clean && tsc -p .",
|
||||||
"start": "node ./dist/main.js",
|
"start": "node ./dist/main.js",
|
||||||
"clean-start": "pnpm build && pnpm start"
|
"clean-start": "pnpm build && pnpm start"
|
||||||
|
|
|
@ -9,7 +9,7 @@ export function checkFile(
|
||||||
const fullPath = dir + file;
|
const fullPath = dir + file;
|
||||||
let final: ServerSideReview[];
|
let final: ServerSideReview[];
|
||||||
|
|
||||||
if (fs.existsSync(dir)) {
|
if (fs.existsSync(fullPath)) {
|
||||||
const data = fs.readFileSync(fullPath, encoding);
|
const data = fs.readFileSync(fullPath, encoding);
|
||||||
|
|
||||||
final = !data.toString().trim() ? [] : JSON.parse(data.toString());
|
final = !data.toString().trim() ? [] : JSON.parse(data.toString());
|
||||||
|
|
Loading…
Reference in a new issue