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
No known key found for this signature in database
GPG Key ID: D7F4589C4D7F81A9

View File

@ -61,7 +61,7 @@ export default class ModManager {
// If no errors are logged, cleanup the log file when the process exits
process.on("exit", () => {
// 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)
}
})