From b591727a505352939b9d6a29e69eff77ef64215e Mon Sep 17 00:00:00 2001 From: tycrek Date: Mon, 30 May 2022 16:02:09 -0600 Subject: [PATCH] Try to avoid crashing on launch --- src/ass.ts | 2 +- src/utils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ass.ts b/src/ass.ts index 78113ec..c6d357a 100644 --- a/src/ass.ts +++ b/src/ass.ts @@ -15,7 +15,7 @@ import { path, log, getTrueHttp, getTrueDomain } from './utils'; //#region Setup - Run first time setup if using Docker (pseudo-process, setup will be run with docker exec) import { doSetup } from './setup'; const configPath = path('config.json'); -if (!fs.existsSync(configPath)) { +if (!fs.existsSync(configPath) || fs.readFileSync(configPath).toString().length === 0) { doSetup(); // @ts-ignore return; diff --git a/src/utils.ts b/src/utils.ts index 9ad9579..c34a5ab 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -18,7 +18,7 @@ try { var { useSsl, port, domain, isProxied, diskFilePath, s3bucket, s3endpoint, s3usePathStyle } = require('../config.json'); // skipcq: JS-0239, JS-0102 } catch (ex) { // @ts-ignore - if (ex.code !== 'MODULE_NOT_FOUND') console.error(ex); + if (ex.code !== 'MODULE_NOT_FOUND' || Object.prototype.toString.call(ex).includes('Unexpected end of JSON input')) console.error(ex); } export function getTrueHttp() {