Comparing version 8.2.0 to 8.2.1
17
boot.js
@@ -405,4 +405,4 @@ 'use strict' | ||
function callWithCbOrNextTick (func, cb, context) { | ||
context = this._server | ||
function callWithCbOrNextTick (func, cb) { | ||
const context = this._server | ||
const err = this._error | ||
@@ -430,6 +430,11 @@ let res | ||
if (this._timeout === 0) { | ||
const wrapCb = (err) => { | ||
this._error = err | ||
cb(this._error) | ||
} | ||
if (func.length === 2) { | ||
func(err, cb) | ||
func(err, wrapCb) | ||
} else { | ||
func(err, context, cb) | ||
func(err, context, wrapCb) | ||
} | ||
@@ -472,4 +477,4 @@ } else { | ||
function closeWithCbOrNextTick (func, cb, context) { | ||
context = this._server | ||
function closeWithCbOrNextTick (func, cb) { | ||
const context = this._server | ||
const isOnCloseHandler = func[this._isOnCloseHandlerKey] | ||
@@ -476,0 +481,0 @@ if (func.length === 0 || func.length === 1) { |
@@ -10,3 +10,3 @@ 'use strict' | ||
function AvvioError (a, b, c) { | ||
if (!(this instanceof AvvioError)) { | ||
if (!new.target) { | ||
return new AvvioError(a, b, c) | ||
@@ -13,0 +13,0 @@ } |
{ | ||
"name": "avvio", | ||
"version": "8.2.0", | ||
"version": "8.2.1", | ||
"description": "Asynchronous bootstrapping of Node applications", | ||
@@ -34,5 +34,5 @@ "main": "boot.js", | ||
"devDependencies": { | ||
"@fastify/pre-commit": "^2.0.2", | ||
"@types/node": "^18.0.0", | ||
"express": "^4.17.1", | ||
"pre-commit": "^1.2.2", | ||
"semver": "^7.1.3", | ||
@@ -39,0 +39,0 @@ "standard": "^17.0.0", |
@@ -25,3 +25,3 @@ # avvio | ||
``` | ||
npm install avvio --save | ||
npm i avvio | ||
``` | ||
@@ -493,3 +493,3 @@ | ||
assert(s1 !== server) | ||
assert(server.isPrototypeOf(s1)) | ||
assert(Object.prototype.isPrototypeOf.call(server, s1)) | ||
assert(s1.count === 1) | ||
@@ -501,3 +501,3 @@ s1.use(second) | ||
assert(s2 !== s1) | ||
assert(s1.isPrototypeOf(s2)) | ||
assert(Object.prototype.isPrototypeOf.isPrototypeOf.call(s1, s2)) | ||
assert(s2.count === 2) | ||
@@ -504,0 +504,0 @@ cb() |
@@ -300,3 +300,3 @@ 'use strict' | ||
t.equal(s, server) | ||
t.notOk(server.isPrototypeOf(s)) | ||
t.notOk(Object.prototype.isPrototypeOf.call(server, s)) | ||
} | ||
@@ -309,1 +309,15 @@ | ||
}) | ||
test('ready queue error', async (t) => { | ||
const app = boot() | ||
app.use(first) | ||
async function first (s, opts) {} | ||
app.ready(function (_, worker, done) { | ||
const error = new Error('kaboom') | ||
done(error) | ||
}) | ||
await t.rejects(app.ready(), { message: 'kaboom' }) | ||
}) |
@@ -274,3 +274,3 @@ 'use strict' | ||
test('await use - fork the promise chain', { only: true }, (t) => { | ||
test('await use - fork the promise chain', (t) => { | ||
t.plan(3) | ||
@@ -277,0 +277,0 @@ const app = {} |
@@ -25,3 +25,3 @@ 'use strict' | ||
t.not(s, server) | ||
t.ok(server.isPrototypeOf(s)) | ||
t.ok(Object.prototype.isPrototypeOf.call(server, s)) | ||
cb() | ||
@@ -46,3 +46,3 @@ }) | ||
t.not(s1, server) | ||
t.ok(server.isPrototypeOf(s1)) | ||
t.ok(Object.prototype.isPrototypeOf.call(server, s1)) | ||
t.equal(s1.count, 1) | ||
@@ -55,3 +55,3 @@ s1.use(second) | ||
t.not(s2, s1) | ||
t.ok(s1.isPrototypeOf(s2)) | ||
t.ok(Object.prototype.isPrototypeOf.call(s1, s2)) | ||
t.equal(s2.count, 2) | ||
@@ -78,3 +78,3 @@ cb() | ||
t.not(s1, server) | ||
t.ok(server.isPrototypeOf(s1)) | ||
t.ok(Object.prototype.isPrototypeOf.call(server, s1)) | ||
t.equal(s1.count, 1) | ||
@@ -90,3 +90,3 @@ s1.use(second) | ||
t.not(s2, s1) | ||
t.ok(s1.isPrototypeOf(s2)) | ||
t.ok(Object.prototype.isPrototypeOf.call(s1, s2)) | ||
t.equal(s2.count, 2) | ||
@@ -98,4 +98,4 @@ cb() | ||
t.not(s3, s1) | ||
t.ok(s1.isPrototypeOf(s3)) | ||
t.notOk(prev.isPrototypeOf(s3)) | ||
t.ok(Object.prototype.isPrototypeOf.call(s1, s3)) | ||
t.notOk(Object.prototype.isPrototypeOf.call(prev, s3)) | ||
t.equal(s3.count, 2) | ||
@@ -122,3 +122,3 @@ cb() | ||
t.not(s1, server) | ||
t.ok(server.isPrototypeOf(s1)) | ||
t.ok(Object.prototype.isPrototypeOf.call(server, s1)) | ||
t.equal(s1.count, 1) | ||
@@ -131,3 +131,3 @@ s1.use(second) | ||
t.not(s2, s1) | ||
t.ok(s1.isPrototypeOf(s2)) | ||
t.ok(Object.prototype.isPrototypeOf.call(s1, s2)) | ||
t.equal(s2.count, 2) | ||
@@ -140,3 +140,3 @@ cb() | ||
t.not(s1, server) | ||
t.ok(server.isPrototypeOf(s1)) | ||
t.ok(Object.prototype.isPrototypeOf.call(server, s1)) | ||
t.equal(s1.count, 1) | ||
@@ -149,3 +149,3 @@ s1.use(fourth) | ||
t.not(s2, s1) | ||
t.ok(s1.isPrototypeOf(s2)) | ||
t.ok(Object.prototype.isPrototypeOf.call(s1, s2)) | ||
t.equal(s2.count, 2) | ||
@@ -189,3 +189,3 @@ cb() | ||
t.not(i, instance) | ||
t.ok(instance.isPrototypeOf(i)) | ||
t.ok(Object.prototype.isPrototypeOf.call(instance, i)) | ||
@@ -242,3 +242,3 @@ i.add('test', noop, (err) => { | ||
t.equal(s, server) | ||
t.notOk(server.isPrototypeOf(s)) | ||
t.notOk(Object.prototype.isPrototypeOf.call(server, s)) | ||
cb() | ||
@@ -267,3 +267,3 @@ } | ||
t.not(s, server) | ||
t.ok(server.isPrototypeOf(s)) | ||
t.ok(Object.prototype.isPrototypeOf.call(server, s)) | ||
cb() | ||
@@ -295,3 +295,3 @@ }, options) | ||
t.not(s, server) | ||
t.ok(server.isPrototypeOf(s)) | ||
t.ok(Object.prototype.isPrototypeOf.call(server, s)) | ||
s.foo = 'bar' | ||
@@ -304,3 +304,3 @@ cb() | ||
t.same(opts, { hello: 'world' }) | ||
t.ok(server.isPrototypeOf(s)) | ||
t.ok(Object.prototype.isPrototypeOf.call(server, s)) | ||
cb() | ||
@@ -374,3 +374,3 @@ }, p => ({ hello: p.bar })) | ||
t.not(s1, server) | ||
t.ok(server.isPrototypeOf(s1)) | ||
t.ok(Object.prototype.isPrototypeOf.call(server, s1)) | ||
t.equal(s1.count, 1) | ||
@@ -385,3 +385,3 @@ s1.after(() => { | ||
t.not(s2, s1) | ||
t.ok(s1.isPrototypeOf(s2)) | ||
t.ok(Object.prototype.isPrototypeOf.call(s1, s2)) | ||
t.equal(s2.count, 2) | ||
@@ -388,0 +388,0 @@ cb() |
Sorry, the diff of this file is not supported yet
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
147148
5000