Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/logger.ts
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