mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
deprecate: remove callback in module definition
This commit is contained in:
parent
78aac2df26
commit
1080dfdbd6
@ -138,32 +138,16 @@ module.exports = class ModuleContainer {
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// Prepare callback
|
||||
const cb = err => {
|
||||
printWarn(
|
||||
'Supporting callbacks is deprecated and will be removed in next releases. Consider using async/await.',
|
||||
src
|
||||
)
|
||||
|
||||
/* istanbul ignore if */
|
||||
if (err) {
|
||||
return reject(err)
|
||||
}
|
||||
resolve()
|
||||
}
|
||||
|
||||
// Call module with `this` context and pass options
|
||||
const result = handler.call(this, options, cb)
|
||||
const result = handler.call(this, options)
|
||||
|
||||
// If module send back a promise
|
||||
if (result && result.then) {
|
||||
return resolve(result)
|
||||
}
|
||||
|
||||
// If not expecting a callback but returns no promise (=synchronous)
|
||||
if (handler.length < 2) {
|
||||
// synchronous
|
||||
return resolve()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,6 @@ test.serial('Deprecated: module.addVendor()', async t => {
|
||||
t.true(buildSpies.warn.calledWithMatch('module: addVendor is no longer necessary'))
|
||||
})
|
||||
|
||||
test.serial('Deprecated: module callback', async t => {
|
||||
t.true(
|
||||
buildSpies.warn.calledWithMatch(
|
||||
'Supporting callbacks is deprecated and will be removed in next releases. Consider using async/await.'
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
test.after.always('Closing server and nuxt.js', async t => {
|
||||
await nuxt.close()
|
||||
|
@ -1,4 +1,3 @@
|
||||
module.exports = function basicModule(options, resolve) {
|
||||
this.addVendor('lodash')
|
||||
resolve()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user