Protect against log file being null or undefined

This commit is contained in:
Kallum Jones
2022-08-04 16:19:57 +01:00
parent 935262ec0f
commit 9c3824e81d

View File

@ -61,7 +61,7 @@ export default class ModManager {
// If no errors are logged, cleanup the log file when the process exits // If no errors are logged, cleanup the log file when the process exits
process.on("exit", () => { process.on("exit", () => {
// If file is only whitespace, i.e. blank // If file is only whitespace, i.e. blank
if (!readFileSync(this.LOG_FILE, "utf-8").trim().length) { if (!readFileSync(this.LOG_FILE, "utf-8")?.trim().length) {
unlinkSync(this.LOG_FILE) unlinkSync(this.LOG_FILE)
} }
}) })