mirror of https://github.com/embarklabs/embark.git
Merge branch 'develop' of github.com:embark-framework/embark into develop
This commit is contained in:
commit
89cba2c588
|
@ -83,8 +83,8 @@ module.exports = {
|
||||||
mocha.suite.timeout(0);
|
mocha.suite.timeout(0);
|
||||||
|
|
||||||
mocha.suite.beforeAll('Wait for deploy', (done) => {
|
mocha.suite.beforeAll('Wait for deploy', (done) => {
|
||||||
global.embark.onReady(() => {
|
global.embark.onReady((err) => {
|
||||||
done();
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ class Test {
|
||||||
this.contracts = {};
|
this.contracts = {};
|
||||||
this.events = new Events();
|
this.events = new Events();
|
||||||
this.ready = true;
|
this.ready = true;
|
||||||
|
this.error = false;
|
||||||
this.builtContracts = {};
|
this.builtContracts = {};
|
||||||
this.compiledContracts = {};
|
this.compiledContracts = {};
|
||||||
|
|
||||||
|
@ -111,12 +112,28 @@ class Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
onReady(callback) {
|
onReady(callback) {
|
||||||
|
const self = this;
|
||||||
if (this.ready) {
|
if (this.ready) {
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
this.events.once('ready', () => {
|
if (this.error) {
|
||||||
|
return callback(this.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
let errorCallback, readyCallback;
|
||||||
|
|
||||||
|
errorCallback = (err) => {
|
||||||
|
self.events.removeListener('ready', readyCallback);
|
||||||
|
callback(err);
|
||||||
|
};
|
||||||
|
|
||||||
|
readyCallback = () => {
|
||||||
|
self.events.removeListener('deployError', errorCallback);
|
||||||
callback();
|
callback();
|
||||||
});
|
};
|
||||||
|
|
||||||
|
this.events.once('ready', readyCallback);
|
||||||
|
this.events.once('deployError', errorCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
config(options, callback) {
|
config(options, callback) {
|
||||||
|
@ -175,12 +192,14 @@ class Test {
|
||||||
},
|
},
|
||||||
function deploy(next) {
|
function deploy(next) {
|
||||||
self._deploy(options, (err, accounts) => {
|
self._deploy(options, (err, accounts) => {
|
||||||
self.ready = true;
|
|
||||||
self.events.emit('ready');
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.red);
|
self.events.emit('deployError', err);
|
||||||
|
self.error = err;
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
self.ready = true;
|
||||||
|
self.error = false;
|
||||||
|
self.events.emit('ready');
|
||||||
next(null, accounts);
|
next(null, accounts);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue