Comparing version 8.1.0 to 8.1.1
{ | ||
"name": "avvio", | ||
"version": "8.1.0", | ||
"version": "8.1.1", | ||
"description": "Asynchronous bootstrapping of Node applications", | ||
@@ -34,3 +34,3 @@ "main": "boot.js", | ||
"devDependencies": { | ||
"@types/node": "^16.0.0", | ||
"@types/node": "^17.0.0", | ||
"express": "^4.17.1", | ||
@@ -37,0 +37,0 @@ "pre-commit": "^1.2.2", |
@@ -152,12 +152,14 @@ 'use strict' | ||
if (err) { | ||
debug('rejecting promise', this.name, err) | ||
this._promise.reject(err) | ||
} else { | ||
debug('resolving promise', this.name) | ||
this._promise.resolve() | ||
} | ||
this._promise = null | ||
process.nextTick(() => { | ||
if (err) { | ||
debug('rejecting promise', this.name, err) | ||
this._promise.reject(err) | ||
} else { | ||
debug('resolving promise', this.name) | ||
this._promise.resolve() | ||
} | ||
this._promise = null | ||
process.nextTick(cb, err) | ||
process.nextTick(cb, err) | ||
}) | ||
}) | ||
@@ -164,0 +166,0 @@ this.q.resume() |
@@ -7,2 +7,4 @@ 'use strict' | ||
const sleep = promisify(setTimeout) | ||
const fs = require('fs').promises | ||
const path = require('path') | ||
@@ -251,3 +253,3 @@ test('await after - nested plugins with same tick callbacks', async (t) => { | ||
t.ok(firstLoaded, 'first is loaded') | ||
t.notOk(secondLoaded, 'second is not loaded') | ||
t.ok(secondLoaded, 'second is loaded') | ||
t.notOk(thirdLoaded, 'third is not loaded') | ||
@@ -285,2 +287,52 @@ t.notOk(fourthLoaded, 'fourth is not loaded') | ||
test('without autostart and sync/async plugin mix', async (t) => { | ||
const app = {} | ||
boot(app, { autostart: false }) | ||
t.plan(11) | ||
let firstLoaded = false | ||
let secondLoaded = false | ||
let thirdLoaded = false | ||
app.use(first) | ||
await app.after() | ||
t.ok(firstLoaded, 'first is loaded') | ||
t.notOk(secondLoaded, 'second is not loaded') | ||
t.notOk(thirdLoaded, 'third is not loaded') | ||
const contents = await fs.readFile(path.join(__dirname, 'fixtures', 'dummy.txt'), 'utf-8') | ||
t.equal(contents, 'hello, world!') | ||
app.use(second) | ||
await app.after() | ||
t.ok(firstLoaded, 'first is loaded') | ||
t.ok(secondLoaded, 'second is loaded') | ||
t.notOk(thirdLoaded, 'third is not loaded') | ||
await sleep(10) | ||
app.use(third) | ||
await app.after() | ||
t.ok(firstLoaded, 'first is loaded') | ||
t.ok(secondLoaded, 'second is loaded') | ||
t.ok(thirdLoaded, 'third is loaded') | ||
await app.ready() | ||
async function first () { | ||
firstLoaded = true | ||
} | ||
async function second () { | ||
const contents = await fs.readFile(path.join(__dirname, 'fixtures', 'dummy.txt'), 'utf-8') | ||
t.equal(contents, 'hello, world!') | ||
secondLoaded = true | ||
} | ||
async function third (app) { | ||
await sleep(10) | ||
thirdLoaded = true | ||
} | ||
}) | ||
test('without autostart', async (t) => { | ||
@@ -287,0 +339,0 @@ const app = {} |
Sorry, the diff of this file is not supported yet
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
144262
45
4888
1