async contract write

This commit is contained in:
Jonathan Rainville 2018-05-08 09:25:37 -04:00
parent af38383e0f
commit 2dd9e8f2ea
1 changed files with 120 additions and 137 deletions

View File

@ -71,13 +71,16 @@ class Pipeline {
importsList[importName] = importLocation;
});
for (let contractName in contractsJSON) {
async.waterfall([
function writeContracts(next) {
async.each(Object.keys(contractsJSON), (contractName, eachCb) => {
let contractCode = self.buildContractJS(contractName);
let filePath = fs.dappPath(".embark", contractName + '.js');
fs.writeFileSync(filePath, contractCode);
importsList["Embark/contracts/" + contractName] = filePath;
}
fs.writeFile(filePath, contractCode, eachCb);
}, next);
},
function assetFileWrite(next) {
// limit:1 due to issues when downloading required files such as web3.js
async.eachOfLimit(self.assetFiles, 1, function (files, targetFile, cb) {
// limit:1 due to issues when downloading required files such as web3.js
@ -86,8 +89,13 @@ class Pipeline {
file = new File(file); // Re-instantiate a File as through the process, we lose its prototype
self.log("reading " + file.filename);
if (file.filename.indexOf('.js') >= 0) {
if (file.filename.indexOf('.js') < 0) {
return file.content(function (fileContent) {
self.runPlugins(file, fileContent, fileCb);
});
}
// JS files
let realCwd;
async.waterfall([
@ -102,26 +110,6 @@ class Pipeline {
next();
},
//function findImportsPhase2(next) {
// console.log("====> findImports_2");
// self.webpackRun(file.filename, {
// externals: function(context, request, callback) {
// if (request === utils.joinPath(fs.dappPath(), file.filename)) {
// callback();
// } else {
// //if (request.indexOf('Embark/contracts/') === 0) {
// // let contractName = request.split('/')[2];
// // let contractCode = self.buildContractJS(contractName);
// // let filePath = utils.joinPath(fs.dappPath(), ".embark", contractName + '.js');
// // fs.writeFileSync(filePath, contractCode);
// // importsList[request] = filePath;
// //}
// callback(null, "amd " + Math.random());
// }
// }
// }, true, importsList, next);
//},
function runWebpack(next) {
self.webpackRun(file.filename, {}, true, importsList, true, next);
},
@ -163,11 +151,6 @@ class Pipeline {
fileCb(null, contentFile);
});
} else {
file.content(function (fileContent) {
self.runPlugins(file, fileContent, fileCb);
});
}
},
function (err, contentFiles) {
if (err) {
@ -201,14 +184,14 @@ class Pipeline {
return file.content;
}).join("\n");
self.log("writing file ASYNC " + (self.buildDir + targetFile).bold.dim);
self.log("writing file " + (self.buildDir + targetFile).bold.dim);
fs.writeFile(self.buildDir + targetFile, content, cb);
}
);
},
function (_err) {
callback();
});
next);
}
], callback);
});
}