mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +00:00
Display proper error when specified plugin isn't found (#3672)
Picking up on https://github.com/nuxt/nuxt.js/pull/3434 -- synced with dev and tests included.
This commit is contained in:
parent
7c7701d622
commit
75d6c4e33a
@ -442,6 +442,13 @@ export default class Builder {
|
|||||||
compilersOptions.push(serverConfig)
|
compilersOptions.push(serverConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check plugins exist then set alias to their real path
|
||||||
|
await Promise.all(this.plugins.map(async (p) => {
|
||||||
|
if (!await fsExtra.pathExists(p.src)) {
|
||||||
|
throw new Error(`Plugin not found: ${r(p.src)}`)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
// Alias plugins to their real path
|
// Alias plugins to their real path
|
||||||
this.plugins.forEach((p) => {
|
this.plugins.forEach((p) => {
|
||||||
const src = this.relativeToBuild(p.src)
|
const src = this.relativeToBuild(p.src)
|
||||||
|
3
test/fixtures/missing-plugin/nuxt.config.js
vendored
Normal file
3
test/fixtures/missing-plugin/nuxt.config.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
plugins: ['~/plugins/missing.js']
|
||||||
|
}
|
@ -43,4 +43,16 @@ describe('nuxt', () => {
|
|||||||
|
|
||||||
await nuxt.close()
|
await nuxt.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Fail to build when specified plugin isn\'t found', () => {
|
||||||
|
const nuxt = new Nuxt({
|
||||||
|
dev: false,
|
||||||
|
rootDir: resolve(__dirname, '..', 'fixtures', 'missing-plugin')
|
||||||
|
})
|
||||||
|
|
||||||
|
return new Builder(nuxt).build().catch((err) => {
|
||||||
|
const s = String(err)
|
||||||
|
expect(s.includes('Plugin not found')).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user