mirror of https://github.com/embarklabs/embark.git
test
This commit is contained in:
parent
1fcfaad5f4
commit
c725f2878f
|
@ -8,14 +8,15 @@ class GraphGenerator {
|
|||
this.events = embark.events;
|
||||
this.contracts = [];
|
||||
|
||||
this.events.setCommandHandler("graph:create", function(options, cb) {
|
||||
self.generate(options);
|
||||
this.events.setCommandHandler("graph:create", async function(options, cb) {
|
||||
await self.generate(options);
|
||||
console.dir("generate done")
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
||||
/*eslint complexity: ["error", 21]*/
|
||||
generate(options) {
|
||||
async generate(options) {
|
||||
const self = this;
|
||||
let id = 0;
|
||||
let contractString = "";
|
||||
|
@ -24,8 +25,15 @@ class GraphGenerator {
|
|||
let contractInheritance = {};
|
||||
let contractsDependencies = {};
|
||||
|
||||
console.dir("-- getContractList");
|
||||
self.contracts = await self.events.get('contracts:list');
|
||||
console.dir("-- getContractList done");
|
||||
|
||||
async.waterfall([
|
||||
function getContractList(next) {
|
||||
// self.contracts = await self.events.get('contracts:list');
|
||||
// console.dir("getContractList done");
|
||||
// next();
|
||||
self.events.request('contracts:list', (err, contracts) => {
|
||||
self.contracts = contracts;
|
||||
next();
|
||||
|
|
|
@ -70,18 +70,31 @@ EventEmitter.prototype.request = function() {
|
|||
};
|
||||
|
||||
EventEmitter.prototype.get = function() {
|
||||
let self = this;
|
||||
let requestName = arguments[0];
|
||||
let other_args = [].slice.call(arguments, 1);
|
||||
|
||||
log("get: ", requestName);
|
||||
warnIfLegacy(requestName);
|
||||
const listenerName = 'get:' + requestName;
|
||||
const listenerName = 'request:' + requestName;
|
||||
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
return this.emit(listenerName, ...other_args, (err, res) => {
|
||||
if (err) return reject(err);
|
||||
let promise = new Promise(function(resolve, reject) {
|
||||
let cb = (err, res) => {
|
||||
console.dir("got response!")
|
||||
console.dir("err")
|
||||
console.dir("res")
|
||||
console.dir(res)
|
||||
if (err) {
|
||||
console.dir("rejecting")
|
||||
console.dir(err)
|
||||
return reject(err);
|
||||
}
|
||||
console.dir("resolving")
|
||||
console.dir(res)
|
||||
return resolve(res);
|
||||
})
|
||||
}
|
||||
other_args.push(cb);
|
||||
return self.emit(listenerName, ...other_args)
|
||||
});
|
||||
|
||||
return promise;
|
||||
|
|
Loading…
Reference in New Issue