Skip to content

Commit

Permalink
Run stream.destroy only on node > 8
Browse files Browse the repository at this point in the history
  • Loading branch information
dex4er committed Feb 2, 2018
1 parent c62d2d0 commit df079ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/file-timestamp-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class FileTimestampStream extends Writable {
if (this.stream) {
this.stream.destroy()
this.stream.removeListener('error', this._streamErrorHandler)
this.stream = undefined
}
super._destroy(err, callback)
}
Expand Down
16 changes: 10 additions & 6 deletions test/file-timestamp-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ Feature('Test file-timestamp-stream module', () => {
return finished.should.be.true
})

And('stream can be destroyed', () => {
wstream.destroy()
})
if (typeof wstream.destroy === 'function') {
And('stream can be destroyed', () => {
wstream.destroy()
})
}
})

Scenario('Custom filename generator', () => {
Expand Down Expand Up @@ -227,8 +229,10 @@ Feature('Test file-timestamp-stream module', () => {
error.should.have.property('message').that.equals('badwrite')
})

And('stream can be destroyed', () => {
wstream.destroy(error)
})
if (typeof wstream.destroy === 'function') {
And('stream can be destroyed', () => {
wstream.destroy()
})
}
})
})

0 comments on commit df079ad

Please sign in to comment.