Skip to content

Commit

Permalink
fix: use sync fs methods in writeFileTree (#2341)
Browse files Browse the repository at this point in the history
closes #2275

Iterating over async functions would put too many write calls in I/O
queue in the same time, leading to weird bugs.
  • Loading branch information
haoqunjiang authored Sep 3, 2018
1 parent 5efbd1b commit ba15fa2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/@vue/cli/lib/util/writeFileTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ module.exports = async function writeFileTree (dir, files, previousFiles) {
if (previousFiles) {
await deleteRemovedFiles(dir, files, previousFiles)
}
return Promise.all(Object.keys(files).map(async (name) => {
Object.keys(files).forEach((name) => {
const filePath = path.join(dir, name)
await fs.ensureDir(path.dirname(filePath))
await fs.writeFile(filePath, files[name])
}))
fs.ensureDirSync(path.dirname(filePath))
fs.writeFileSync(filePath, files[name])
})
}

0 comments on commit ba15fa2

Please sign in to comment.