Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

fix(logger): close opened file descriptor in '.setWrite()' (for unit tests on windows) #5411

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ export class Logger {
if (opt_logFile) {
logFile = opt_logFile;
}

// if fd already opened, close it
// need it for windows, https://stackoverflow.com/a/20801823/2519073
if (typeof Logger.fd === 'number') {
fs.closeSync(Logger.fd);
Logger.fd = void 0;
}

Logger.writeTo = writeTo;
if (Logger.writeTo == WriteTo.FILE || Logger.writeTo == WriteTo.BOTH) {
Logger.fd = fs.openSync(path.resolve(logFile), 'a');
Expand Down