more async

This commit is contained in:
Jonathan Rainville 2018-05-08 09:02:46 -04:00
parent 1d5f015aaa
commit 1fe6f4ee2c
2 changed files with 20 additions and 15 deletions

View File

@ -11,6 +11,10 @@ function mkdirp() {
return fs.mkdirp.apply(fs.mkdirp, arguments);
}
function copy() {
return fs.copy.apply(fs.copy, arguments);
}
function copySync() {
return fs.copySync.apply(fs.copySync, arguments);
}
@ -77,6 +81,7 @@ function createWriteStream() {
module.exports = {
mkdirpSync,
mkdirp,
copy,
copySync,
readFile,
readFileSync,

View File

@ -185,13 +185,15 @@ class Pipeline {
targetDir = targetDir + '/';
}
contentFiles.map(function (file) {
async.each(contentFiles, function (file, mapCb) {
let filename = file.filename.replace(file.basedir + '/', '');
self.log("writing file " + (self.buildDir + targetDir + filename).bold.dim);
fs.copySync(file.path, self.buildDir + targetDir + filename, {overwrite: true});
});
} else {
fs.copy(file.path, self.buildDir + targetDir + filename, {overwrite: true}, mapCb);
}, cb);
return;
}
let content = contentFiles.map(function (file) {
if (file === undefined) {
return "";
@ -199,14 +201,12 @@ class Pipeline {
return file.content;
}).join("\n");
self.log("writing file " + (self.buildDir + targetFile).bold.dim);
fs.writeFileSync(self.buildDir + targetFile, content);
}
cb();
self.log("writing file ASYNC " + (self.buildDir + targetFile).bold.dim);
fs.writeFile(self.buildDir + targetFile, content, cb);
}
);
},
function (_err, _results) {
function (_err) {
callback();
});
});