Comparing version 5.8.1 to 5.9.0
22
boot.js
@@ -365,7 +365,23 @@ 'use strict' | ||
function _encapsulateThreeParam (err, cb) { | ||
var res | ||
if (!func) { | ||
process.nextTick(cb) | ||
} else if (func.length === 0 || func.length === 1) { | ||
func(err) | ||
process.nextTick(cb) | ||
} else if (func.length === 0) { | ||
res = func() | ||
if (res && res.then) { | ||
res.then(function () { | ||
process.nextTick(cb, err) | ||
}, cb) | ||
} else { | ||
process.nextTick(cb, err) | ||
} | ||
} else if (func.length === 1) { | ||
res = func(err) | ||
if (res && res.then) { | ||
res.then(function () { | ||
process.nextTick(cb) | ||
}, cb) | ||
} else { | ||
process.nextTick(cb) | ||
} | ||
} else if (func.length === 2) { | ||
@@ -372,0 +388,0 @@ func(err, cb) |
{ | ||
"name": "avvio", | ||
"version": "5.8.1", | ||
"version": "5.9.0", | ||
"description": "Asynchronous bootstrapping of Node applications", | ||
@@ -5,0 +5,0 @@ "main": "boot.js", |
@@ -183,1 +183,47 @@ 'use strict' | ||
}) | ||
test('after wrapped', async (t) => { | ||
t.plan(15) | ||
const app = {} | ||
boot(app) | ||
let firstLoaded = false | ||
let secondLoaded = false | ||
let thirdLoaded = false | ||
app.use(first) | ||
async function first (s, opts) { | ||
t.notOk(firstLoaded, 'first is not loaded') | ||
t.notOk(secondLoaded, 'second is not loaded') | ||
t.notOk(thirdLoaded, 'third is not loaded') | ||
firstLoaded = true | ||
s.after(second) | ||
s.after(third) | ||
} | ||
async function second (err) { | ||
t.error(err) | ||
t.ok(firstLoaded, 'first is loaded') | ||
t.notOk(secondLoaded, 'second is not loaded') | ||
t.notOk(thirdLoaded, 'third is not loaded') | ||
await sleep(10) | ||
secondLoaded = true | ||
} | ||
async function third () { | ||
t.ok(firstLoaded, 'first is loaded') | ||
t.ok(secondLoaded, 'second is loaded') | ||
t.notOk(thirdLoaded, 'third is not loaded') | ||
await sleep(10) | ||
thirdLoaded = true | ||
} | ||
const readyContext = await app.ready() | ||
t.equal(app, readyContext) | ||
t.ok(firstLoaded, 'first is loaded') | ||
t.ok(secondLoaded, 'second is loaded') | ||
t.ok(thirdLoaded, 'third is loaded') | ||
t.pass('booted') | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87579
26
2948