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
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) {
await fsExtra.mkdirp(r(this.options.buildDir, 'dist', 'client'))
await fsExtra.mkdirp(r(this.options.buildDir, 'dist', 'server'))
buildDirs.push(
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
await this.generateRoutesAndFiles()
@ -420,10 +423,8 @@ export default class Builder {
throw new Error(`Could not compile template ${src}: ${err.message}`)
}
const _path = r(this.options.buildDir, dst)
// Ensure parent dir exits
await fsExtra.mkdirp(path.dirname(_path))
// Write file
await fsExtra.writeFile(_path, content, 'utf8')
// Ensure parent dir exits and write file
await fsExtra.outputFile(_path, content, 'utf8')
})
)