Skip to content

Commit

Permalink
Close should not need a callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Jul 13, 2017
1 parent 4371240 commit e9441cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ Boot.prototype.onClose = function (func) {

Boot.prototype.close = function (cb) {
this._error = null
this._closeQ.push(cb)
if (cb) {
this._closeQ.push(cb)
}
process.nextTick(this._closeQ.resume.bind(this._closeQ))
}

Expand Down
13 changes: 13 additions & 0 deletions test/close.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,16 @@ test('close order', (t) => {
})
})
})

test('close without a cb', (t) => {
t.plan(1)

const app = boot()

app.onClose((err, instance, done) => {
t.error(err)
done()
})

app.close()
})

0 comments on commit e9441cc

Please sign in to comment.