Skip to content

Commit 398aff3

Browse files
committed
fix multiple issues with multiple file writes
1 parent be7d4b0 commit 398aff3

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

lib/contracts/code_generator.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,64 +28,63 @@ class CodeGenerator {
2828
let self = this;
2929

3030
// deprecated events; to remove in embark 2.7.0
31-
this.events.setCommandHandler('abi-vanila', function(cb) {
31+
this.events.setCommandHandlerOnce('abi-vanila', function(cb) {
3232
let vanillaABI = self.generateABI({useEmbarkJS: false});
3333
let contractsJSON = self.generateContractsJSON();
3434

3535
cb(vanillaABI, contractsJSON);
3636
});
3737

38-
this.events.setCommandHandler('abi', function(cb) {
38+
this.events.setCommandHandlerOnce('abi', function(cb) {
3939
let embarkJSABI = self.generateABI({useEmbarkJS: true});
4040
let contractsJSON = self.generateContractsJSON();
4141

4242
cb(embarkJSABI, contractsJSON);
4343
});
4444

45-
this.events.setCommandHandler('abi-contracts-vanila', function(cb) {
45+
this.events.setCommandHandlerOnce('abi-contracts-vanila', function(cb) {
4646
let vanillaContractsABI = self.generateContracts(false, true, false);
4747
let contractsJSON = self.generateContractsJSON();
4848

4949
cb(vanillaContractsABI, contractsJSON);
5050
});
5151

52-
this.events.setCommandHandler('abi-vanila-deployment', function(cb) {
52+
this.events.setCommandHandlerOnce('abi-vanila-deployment', function(cb) {
5353
let vanillaABI = self.generateABI({useEmbarkJS: false, deployment: true});
5454
let contractsJSON = self.generateContractsJSON();
5555

5656
cb(vanillaABI, contractsJSON);
5757
});
5858

5959
// new events
60-
this.events.setCommandHandler('code-vanila', function(cb) {
60+
this.events.setCommandHandlerOnce('code-vanila', function(cb) {
6161
let vanillaABI = self.generateABI({useEmbarkJS: false});
6262
let contractsJSON = self.generateContractsJSON();
6363

6464
cb(vanillaABI, contractsJSON);
6565
});
6666

67-
this.events.setCommandHandler('code', function(cb) {
67+
this.events.setCommandHandlerOnce('code', function(cb) {
6868
let embarkJSABI = self.generateABI({useEmbarkJS: true});
6969
let contractsJSON = self.generateContractsJSON();
7070

7171
cb(embarkJSABI, contractsJSON);
7272
});
7373

74-
this.events.setCommandHandler('code-contracts-vanila', function(cb) {
74+
this.events.setCommandHandlerOnce('code-contracts-vanila', function(cb) {
7575
let vanillaContractsABI = self.generateContracts(false, true, false);
7676
let contractsJSON = self.generateContractsJSON();
7777

7878
cb(vanillaContractsABI, contractsJSON);
7979
});
8080

81-
this.events.setCommandHandler('code-vanila-deployment', function(cb) {
81+
this.events.setCommandHandlerOnce('code-vanila-deployment', function(cb) {
8282
let vanillaABI = self.generateABI({useEmbarkJS: false, deployment: true});
8383
let contractsJSON = self.generateContractsJSON();
8484

8585
cb(vanillaABI, contractsJSON);
8686
});
8787

88-
8988
}
9089

9190
generateProvider(isDeployment) {
@@ -222,8 +221,6 @@ class CodeGenerator {
222221
result += Templates.exec_when_env_loaded({block: block});
223222
}
224223

225-
console.log(result);
226-
227224
return result;
228225
}
229226

lib/core/events.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,11 @@ EventEmitter.prototype.setCommandHandler = function(requestName, cb) {
4242
});
4343
};
4444

45+
EventEmitter.prototype.setCommandHandlerOnce = function(requestName, cb) {
46+
log("setting command handler for: ", requestName);
47+
return this.once('request:' + requestName, function(_cb) {
48+
cb.call(this, _cb);
49+
});
50+
};
51+
4552
module.exports = EventEmitter;

0 commit comments

Comments
 (0)