Skip to content

Commit

Permalink
Support returning an instance of server in after(cb) (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina authored May 8, 2020
1 parent 92a4630 commit 665b3e1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ Plugin.prototype.loadedSoFar = function () {
} else {
setup()
}
} else {
res = Promise.resolve()
}

return res
Expand Down
20 changes: 20 additions & 0 deletions test/after-self-promise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict'

const { test } = require('tap')
const boot = require('..')

test('after does not await itself', async (t) => {
t.plan(3)

const app = {}
boot(app)

app.use(async (app) => {
t.pass('plugin init')
})
app.after(() => app)
t.pass('reachable')

await app.ready()
t.pass('reachable')
})

0 comments on commit 665b3e1

Please sign in to comment.