From 5bf89b0fea071413763c717a2e3f0cd38a2e83d1 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 20 Jul 2018 20:22:12 +0300 Subject: [PATCH] move copmiler to a module --- lib/core/engine.js | 6 +----- .../compiler.js => modules/compiler/index.js} | 13 ++++++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) rename lib/{contracts/compiler.js => modules/compiler/index.js} (82%) diff --git a/lib/core/engine.js b/lib/core/engine.js index d4bbbe1a..8403af32 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 e6c4fc23..017d2055 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) {