async some functions
This commit is contained in:
parent
e85d8b1ae5
commit
1d5f015aaa
|
@ -53,6 +53,10 @@ function existsSync() {
|
|||
return fs.existsSync.apply(fs.existsSync, arguments);
|
||||
}
|
||||
|
||||
function access() {
|
||||
return fs.access.apply(fs.access, arguments);
|
||||
}
|
||||
|
||||
function removeSync() {
|
||||
return fs.removeSync.apply(fs.removeSync, arguments);
|
||||
}
|
||||
|
@ -81,6 +85,7 @@ module.exports = {
|
|||
writeFileSync,
|
||||
readJSONSync,
|
||||
writeJSONSync,
|
||||
access,
|
||||
existsSync,
|
||||
removeSync,
|
||||
embarkPath,
|
||||
|
|
|
@ -129,20 +129,39 @@ class Pipeline {
|
|||
function changeCwdBack(next) {
|
||||
process.chdir(realCwd);
|
||||
next();
|
||||
},
|
||||
|
||||
function checkFile(next) {
|
||||
fs.access('./.embark/' + file.filename, (err) => {
|
||||
if (err) {
|
||||
self.log("couldn't find file: " + file.filename);
|
||||
return next("couldn't find file: " + file.filename);
|
||||
}
|
||||
next();
|
||||
});
|
||||
},
|
||||
|
||||
function readFile(next) {
|
||||
fs.readFile('./.embark/' + file.filename, (err, data) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
next(null, data.toString());
|
||||
});
|
||||
},
|
||||
|
||||
function runPluginsOnContent(fileContent, next) {
|
||||
self.runPlugins(file, fileContent, next);
|
||||
}
|
||||
|
||||
], function(err, _result) {
|
||||
], function(err, contentFile) {
|
||||
if (err) {
|
||||
process.chdir(realCwd);
|
||||
self.log(err);
|
||||
return fileCb(err);
|
||||
}
|
||||
if (!fs.existsSync('./.embark/' + file.filename)) {
|
||||
self.log("couldn't find file: " + file.filename);
|
||||
return fileCb("couldn't find file: " + file.filename);
|
||||
}
|
||||
let fileContent = fs.readFileSync('./.embark/' + file.filename).toString();
|
||||
self.runPlugins(file, fileContent, fileCb);
|
||||
|
||||
fileCb(null, contentFile);
|
||||
});
|
||||
} else {
|
||||
file.content(function(fileContent) {
|
||||
|
|
Loading…
Reference in New Issue