Skip to content

Commit

Permalink
Added: Checks for empty History file and repopulates
Browse files Browse the repository at this point in the history
  • Loading branch information
GameGodS3 committed Jul 23, 2022
1 parent 368ee53 commit 8eefa77
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ const getHistory = () => {
fs.readFile("instanceHistory.json", (err, data) => {
if (err) reject(err);

let history = JSON.parse(data);
resolve(history);
try {
let history = JSON.parse(data);
resolve(history);
} catch (e) {
const historyObj = {
history: [],
};
setHistory(historyObj).then(resolve(historyObj));
}
});
});
};
Expand Down

0 comments on commit 8eefa77

Please sign in to comment.