Skip to content

Commit

Permalink
fix: the journal file is not cached anymore.
Browse files Browse the repository at this point in the history
Before this to reload changes we needed to restart the app.
  • Loading branch information
kajyr committed Nov 10, 2021
1 parent 8167a13 commit bfce005
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions backend/dal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ export function addTransaction(data: Transaction): Promise<void> {
return fs.appendFile(fullFile, `\n${formatTransaction(data)}`, "utf8");
}

let fileContents: ParseResult;

export function readFile(): Promise<ParseResult> {
if (fileContents) {
return Promise.resolve(fileContents);
}

const readStream = createReadStream(fullFile);

return parse(readStream).then((contents) => {
fileContents = contents;
readStream.close();
return contents;
});
}

0 comments on commit bfce005

Please sign in to comment.