mirror of
https://git.bits.team/Bits/mod-manager.git
synced 2024-12-22 04:18:21 -05:00
Cleanup blank log files
This commit is contained in:
parent
e913bafb1e
commit
e808a4f414
@ -10,6 +10,7 @@ import {Logger, pino} from "pino"
|
||||
import {ListCommand} from "./commands/list_command.js";
|
||||
import UninstallCommand from "./commands/uninstall_command.js";
|
||||
import EssentialCommand from "./commands/essential_command.js";
|
||||
import {readFileSync, unlinkSync} from "fs";
|
||||
|
||||
|
||||
export default class ModManager {
|
||||
@ -57,6 +58,14 @@ export default class ModManager {
|
||||
setTimeout(() => process.exit(1), 1)
|
||||
})
|
||||
|
||||
// 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) {
|
||||
unlinkSync(this.LOG_FILE)
|
||||
}
|
||||
})
|
||||
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user