mirror of https://github.com/embarklabs/embark.git
simplify buildContracts and buildWeb3JS methodsgst
This commit is contained in:
parent
4dcd644b7c
commit
8ae6c6a646
|
@ -179,31 +179,39 @@ class Pipeline {
|
|||
);
|
||||
}
|
||||
|
||||
buildContracts(callback) {
|
||||
buildContracts(cb) {
|
||||
const self = this;
|
||||
fs.mkdirp(fs.dappPath(this.buildDir, 'contracts'), (err) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
function makeDirectory(next) {
|
||||
fs.mkdirp(fs.dappPath(self.buildDir, 'contracts'), (err, _result) => {
|
||||
next(err)
|
||||
});
|
||||
},
|
||||
function getContracts(next) {
|
||||
self.events.request('contracts:list', (contracts) => {
|
||||
next(null, contracts);
|
||||
});
|
||||
},
|
||||
function writeContractsJSON(contracts, next) {
|
||||
async.each(contracts, (contract, eachCb) => {
|
||||
fs.writeJson(fs.dappPath(this.buildDir, 'contracts', contract.className + ".json"), contract, {spaces: 2}, eachCb);
|
||||
}, () => {callback()});
|
||||
});
|
||||
});
|
||||
fs.writeJson(fs.dappPath(self.buildDir, 'contracts', contract.className + ".json"), contract, {spaces: 2}, eachCb);
|
||||
}, () => {next()});
|
||||
}
|
||||
], cb);
|
||||
}
|
||||
|
||||
buildWeb3JS(cb) {
|
||||
const self = this;
|
||||
async.waterfall([
|
||||
function makeDirectory(next) {
|
||||
fs.mkdirp(fs.dappPath(".embark"), (err, _result) => {
|
||||
next(err);
|
||||
});
|
||||
},
|
||||
function getWeb3Code(next) {
|
||||
self.events.request('code-generator:web3js', next);
|
||||
},
|
||||
function makeDirectory(code, next) {
|
||||
fs.mkdirp(fs.dappPath(".embark"), (err, _result) => {
|
||||
next(err, code);
|
||||
});
|
||||
},
|
||||
function writeFile(code, next) {
|
||||
fs.writeFile(fs.dappPath(".embark", 'web3_instance.js'), code, next);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue