From 37b35ad46e005ae6c47cb20477244cdf4e7f99b0 Mon Sep 17 00:00:00 2001 From: PolinaBalanyeva <38326946+PolinaBalanyeva@users.noreply.github.com> Date: Mon, 26 Sep 2022 14:41:08 +0900 Subject: [PATCH] debug and created data folder --- src/index.ts | 3 ++- src/json.ts | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index b0dd681..829e27d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,7 +36,8 @@ const interval = 60 * 10; const processing = new Set(); const writing = { id: [0, 0] }; const idJSON = new json('id'); -let ids: Record, speakers: Record; +let ids: Record; +const speakers: Record = {}; const intervalIDs: Record = {}; const twitter = new TwitterWrap({ diff --git a/src/json.ts b/src/json.ts index 6ca5a21..8cf177b 100644 --- a/src/json.ts +++ b/src/json.ts @@ -7,9 +7,9 @@ export default class json { } public async read(): Promise> { const dict: Record = await fs - .access(this.filename + '.json') + .access('data/' + this.filename + '.json') .then(async () => - fs.readFile(this.filename + '.json', { encoding: 'utf-8' }) + fs.readFile('data/' + this.filename + '.json', { encoding: 'utf-8' }) ) .catch(() => '{}') .then((data) => JSON.parse(data) as Record); @@ -28,7 +28,7 @@ export default class json { writingThisFile[1] = 1; while (writingThisFile[0] && writingThisFile[0] > 0) { await fs - .writeFile(this.filename + '.json', JSON.stringify(dict)) + .writeFile('data/' + this.filename + '.json', JSON.stringify(dict)) .then(() => { writingThisFile[0] -= 1; });