fix(generator): improve error handling when build does not exists (#7335)

[release]
This commit is contained in:
Pooya Parsa 2020-05-08 16:37:42 +02:00 committed by GitHub
parent 80396cbf41
commit 631be3a1dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,10 +66,11 @@ export default class Generator {
await this.builder.build() await this.builder.build()
this.isFullStatic = isFullStatic(this.options) this.isFullStatic = isFullStatic(this.options)
} else { } else {
const hasBuilt = await fsExtra.exists(this.srcBuiltPath) const hasBuilt = await fsExtra.exists(path.resolve(this.options.buildDir, 'dist', 'server', 'client.manifest.json'))
if (!hasBuilt) { if (!hasBuilt) {
const fullStaticArgs = isFullStatic(this.options) ? ' --target static' : ''
throw new Error( throw new Error(
`No build files found in ${this.srcBuiltPath}.\nPlease run \`nuxt build --target static\` before calling \`nuxt export\`` `No build files found in ${this.srcBuiltPath}.\nPlease run \`nuxt build${fullStaticArgs}\` before calling \`nuxt export\``
) )
} }
const config = this.getBuildConfig() const config = this.getBuildConfig()