Skip to content

Commit 34c6c39

Browse files
committed
Fix compatibility with Node 6
1 parent 06b8310 commit 34c6c39

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/file-timestamp-stream.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import strftime from 'ultra-strftime'
88
const finished = require('stream.finished') as (stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, callback?: (err: NodeJS.ErrnoException) => void) => () => void // TODO: wait for new typings for node
99

1010
// tslint:disable-next-line:strict-type-predicates
11-
const HAS_DESTROY = typeof WriteStream.prototype.destroy === 'function'
11+
const HAS_DESTROY = typeof Writable.prototype.destroy === 'function'
1212

1313
export interface FileTimestampStreamOptions extends WritableOptions {
1414
flags?: string | null
@@ -95,9 +95,11 @@ export class FileTimestampStream extends Writable {
9595
}
9696
}
9797
if (this.streams.size > 0) {
98-
this.streams.forEach((stream) => {
99-
stream.destroy()
100-
})
98+
if (HAS_DESTROY) {
99+
this.streams.forEach((stream) => {
100+
stream.destroy()
101+
})
102+
}
101103
this.streams.clear()
102104
}
103105

test/lib/mock-fs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class MockWriteStream extends Writable {
1717
}
1818

1919
close (): void {
20-
// ignore
20+
this.end()
2121
}
2222

2323
_write (chunk: any, _encoding: string, callback: (error?: Error | null) => void): void {

0 commit comments

Comments
 (0)