mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
fix(generator): throw an error when Builder is missing (#9663)
This commit is contained in:
parent
1b66e9c688
commit
b565c38f48
@ -84,6 +84,12 @@ export default class Generator {
|
|||||||
await this.nuxt.callHook('export:before', this)
|
await this.nuxt.callHook('export:before', this)
|
||||||
|
|
||||||
if (build) {
|
if (build) {
|
||||||
|
if (!this.builder) {
|
||||||
|
throw new Error(
|
||||||
|
`Could not generate. Make sure a Builder instance is passed to the constructor of Generator class or `getGenerator` function \
|
||||||
|
or disable the build step: \`generate({ build: false })\``)
|
||||||
|
}
|
||||||
|
|
||||||
// Add flag to set process.static
|
// Add flag to set process.static
|
||||||
this.builder.forGenerate()
|
this.builder.forGenerate()
|
||||||
|
|
||||||
|
@ -98,6 +98,13 @@ describe('generator: initialize', () => {
|
|||||||
expect(generator.initDist).not.toBeCalled()
|
expect(generator.initDist).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('should throw error when build is not disabled, but Builder instance is omitted', async () => {
|
||||||
|
const nuxt = createNuxt()
|
||||||
|
const generator = new Generator(nuxt)
|
||||||
|
|
||||||
|
await expect(generator.initiate()).rejects.toThrow('Could not generate')
|
||||||
|
})
|
||||||
|
|
||||||
test('should init routes with generate.routes and routes.json', async () => {
|
test('should init routes with generate.routes and routes.json', async () => {
|
||||||
const nuxt = createNuxt()
|
const nuxt = createNuxt()
|
||||||
nuxt.options = {
|
nuxt.options = {
|
||||||
|
Loading…
Reference in New Issue
Block a user