nit: Make fs more parallel 😂👌 (#3795)

This commit is contained in:
Mihal Malostanidis 2018-08-24 21:20:57 +03:00 committed by Clark Du
parent ac841edf62
commit a2168ae4f9

View File

@ -133,11 +133,14 @@ export default class Builder {
// Create .nuxt/, .nuxt/components and .nuxt/dist folders // Create .nuxt/, .nuxt/components and .nuxt/dist folders
await fsExtra.remove(r(this.options.buildDir)) await fsExtra.remove(r(this.options.buildDir))
await fsExtra.mkdirp(r(this.options.buildDir, 'components')) const buildDirs = [r(this.options.buildDir, 'components')]
if (!this.options.dev) { if (!this.options.dev) {
await fsExtra.mkdirp(r(this.options.buildDir, 'dist', 'client')) buildDirs.push(
await fsExtra.mkdirp(r(this.options.buildDir, 'dist', 'server')) r(this.options.buildDir, 'dist', 'client'),
r(this.options.buildDir, 'dist', 'server')
)
} }
await Promise.all(buildDirs.map(dir => fsExtra.mkdirp(dir)))
// Generate routes and interpret the template files // Generate routes and interpret the template files
await this.generateRoutesAndFiles() await this.generateRoutesAndFiles()
@ -420,10 +423,8 @@ export default class Builder {
throw new Error(`Could not compile template ${src}: ${err.message}`) throw new Error(`Could not compile template ${src}: ${err.message}`)
} }
const _path = r(this.options.buildDir, dst) const _path = r(this.options.buildDir, dst)
// Ensure parent dir exits // Ensure parent dir exits and write file
await fsExtra.mkdirp(path.dirname(_path)) await fsExtra.outputFile(_path, content, 'utf8')
// Write file
await fsExtra.writeFile(_path, content, 'utf8')
}) })
) )