diff --git a/lib/core/engine.js b/lib/core/engine.js index d4bbbe1af..8403af324 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -192,11 +192,7 @@ class Engine { deploymentService(options) { let self = this; - const Compiler = require('../contracts/compiler.js'); - let compiler = new Compiler({plugins: self.plugins, logger: self.logger}); - this.events.setCommandHandler("compiler:contracts", function(contractFiles, cb) { - compiler.compile_contracts(contractFiles, cb); - }); + this.registerModule('compiler', {plugins: self.plugins}); this.ipc = new IPC({logger: this.logger, ipcRole: options.ipcRole}); if (this.ipc.isServer()) { diff --git a/lib/contracts/compiler.js b/lib/modules/compiler/index.js similarity index 82% rename from lib/contracts/compiler.js rename to lib/modules/compiler/index.js index e6c4fc23e..017d20553 100644 --- a/lib/contracts/compiler.js +++ b/lib/modules/compiler/index.js @@ -1,9 +1,16 @@ -let async = require('../utils/async_extend.js'); +let async = require('../../utils/async_extend.js'); class Compiler { - constructor(options) { + constructor(embark, options) { + const self = this; this.plugins = options.plugins; - this.logger = options.logger; + this.events = embark.events; + this.logger = embark.logger; + + this.events.setCommandHandler("compiler:contracts", function(contractFiles, cb) { + self.compile_contracts(contractFiles, cb); + }); + } compile_contracts(contractFiles, cb) {