Don't use sync functions

This commit is contained in:
Sébastien Chopin 2016-11-10 14:51:40 +01:00
parent a8776de913
commit d5230accaf

View File

@ -9,6 +9,7 @@ const { resolve, join, dirname } = require('path')
const copy = pify(fs.copy)
const remove = pify(fs.remove)
const writeFile = pify(fs.writeFile)
const mkdirp = pify(fs.mkdirp)
const defaults = {
dir: 'dist',
@ -53,8 +54,10 @@ module.exports = function () {
debug('Generate file: ' + path)
path = join(distPath, path)
// Make sure the sub folders are created
fs.mkdirsSync(dirname(path))
return writeFile(path, html, 'utf8')
return co(function * () {
yield mkdirp(dirname(path))
yield writeFile(path, html, 'utf8')
})
})
promises.push(promise)
})