Skip to content

Commit 379f358

Browse files
committed
Support node 10
1 parent 9bb2797 commit 379f358

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/fileRotator.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class FileRotator extends EventEmitter {
4747

4848
async rotate() {
4949
if (this._currentHandle) {
50-
await this._currentHandle.close();
50+
await this._closeFileHandle();
51+
this._currentHandle = null;
5152
}
5253
if (this._gzip) {
5354
await this._gzipCurrentFile();
@@ -61,7 +62,8 @@ class FileRotator extends EventEmitter {
6162

6263
async shutdown() {
6364
if (this._currentHandle) {
64-
await this._currentHandle.close();
65+
await this._closeFileHandle();
66+
this._currentHandle = null;
6567
}
6668
}
6769

@@ -163,6 +165,14 @@ class FileRotator extends EventEmitter {
163165
fileNumber -= 1;
164166
}
165167
}
168+
169+
async _closeFileHandle() {
170+
if (this._currentHandle) {
171+
const closePromise = this._currentHandle.close();
172+
this._currentHandle = null;
173+
await closePromise;
174+
}
175+
}
166176
}
167177

168178
module.exports = FileRotator;

test/filerotate.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('RotatingFileStream', function () {
2525

2626
it('Processes client configuration', async function () {
2727
const rfs = new RotatingFileStream(testConfig);
28-
assert.strictEqual(rfs._path, 'logs/foo.log');
28+
assert.strictEqual(rfs._path, testConfig.path);
2929
await rfs.end();
3030
});
3131

0 commit comments

Comments
 (0)