mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-03 02:43:25 +00:00
async buildContracts
This commit is contained in:
parent
2dd9e8f2ea
commit
4ec7fbb9db
@ -53,6 +53,10 @@ function writeJSONSync() {
|
|||||||
return fs.writeJSONSync.apply(fs.writeJSONSync, arguments);
|
return fs.writeJSONSync.apply(fs.writeJSONSync, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function writeJson() {
|
||||||
|
return fs.writeJson.apply(fs.writeJson, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
function existsSync() {
|
function existsSync() {
|
||||||
return fs.existsSync.apply(fs.existsSync, arguments);
|
return fs.existsSync.apply(fs.existsSync, arguments);
|
||||||
}
|
}
|
||||||
@ -89,6 +93,7 @@ module.exports = {
|
|||||||
writeFile,
|
writeFile,
|
||||||
writeFileSync,
|
writeFileSync,
|
||||||
readJSONSync,
|
readJSONSync,
|
||||||
|
writeJson,
|
||||||
writeJSONSync,
|
writeJSONSync,
|
||||||
access,
|
access,
|
||||||
existsSync,
|
existsSync,
|
||||||
|
@ -53,16 +53,16 @@ class Pipeline {
|
|||||||
|
|
||||||
build(abi, contractsJSON, path, callback) {
|
build(abi, contractsJSON, path, callback) {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
const importsList = {};
|
||||||
|
|
||||||
this.buildContracts(contractsJSON);
|
async.waterfall([
|
||||||
|
function buildTheContracts(next) {
|
||||||
self.buildWeb3JS(function (err) {
|
self.buildContracts(contractsJSON, next);
|
||||||
if (err) {
|
},
|
||||||
return callback(err);
|
function buildWeb3(next) {
|
||||||
}
|
self.buildWeb3JS(next);
|
||||||
|
},
|
||||||
let importsList = {};
|
function createImportList(next) {
|
||||||
|
|
||||||
importsList["Embark/EmbarkJS"] = fs.dappPath(".embark", 'embark.js');
|
importsList["Embark/EmbarkJS"] = fs.dappPath(".embark", 'embark.js');
|
||||||
importsList["Embark/web3"] = fs.dappPath(".embark", 'web3_instance.js');
|
importsList["Embark/web3"] = fs.dappPath(".embark", 'web3_instance.js');
|
||||||
|
|
||||||
@ -71,7 +71,8 @@ class Pipeline {
|
|||||||
importsList[importName] = importLocation;
|
importsList[importName] = importLocation;
|
||||||
});
|
});
|
||||||
|
|
||||||
async.waterfall([
|
next();
|
||||||
|
},
|
||||||
function writeContracts(next) {
|
function writeContracts(next) {
|
||||||
async.each(Object.keys(contractsJSON), (contractName, eachCb) => {
|
async.each(Object.keys(contractsJSON), (contractName, eachCb) => {
|
||||||
let contractCode = self.buildContractJS(contractName);
|
let contractCode = self.buildContractJS(contractName);
|
||||||
@ -192,7 +193,6 @@ class Pipeline {
|
|||||||
next);
|
next);
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
runPlugins(file, fileContent, fileCb) {
|
runPlugins(file, fileContent, fileCb) {
|
||||||
@ -298,13 +298,16 @@ class Pipeline {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
buildContracts(contractsJSON) {
|
buildContracts(contractsJSON, callback) {
|
||||||
fs.mkdirpSync(fs.dappPath(this.buildDir, 'contracts'));
|
fs.mkdirp(fs.dappPath(this.buildDir, 'contracts'), (err) => {
|
||||||
|
if (err) {
|
||||||
for (let className in contractsJSON) {
|
return callback(err);
|
||||||
let contract = contractsJSON[className];
|
|
||||||
fs.writeJSONSync(fs.dappPath(this.buildDir, 'contracts', className + ".json"), contract, {spaces: 2});
|
|
||||||
}
|
}
|
||||||
|
async.each(Object.keys(contractsJSON), (className, eachCb) => {
|
||||||
|
let contract = contractsJSON[className];
|
||||||
|
fs.writeJson(fs.dappPath(this.buildDir, 'contracts', className + ".json"), contract, {spaces: 2}, eachCb);
|
||||||
|
}, callback);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
buildContractJS(contractName) {
|
buildContractJS(contractName) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user