From 2a6d1cf3fea4915b390deca04bbcb14098c7b0d2 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 10 Jul 2018 08:49:08 -0400 Subject: [PATCH] remove use of initConfig --- lib/cmd.js | 16 ---------------- lib/cmds/blockchain/blockchain.js | 3 ++- lib/cmds/blockchain/blockchainProcess.js | 1 - lib/core/engine.js | 2 +- lib/index.js | 10 +--------- 5 files changed, 4 insertions(+), 28 deletions(-) diff --git a/lib/cmd.js b/lib/cmd.js index 2399d2e10..a0c330991 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -105,10 +105,6 @@ class Cmd { _options.logLevel = _options.loglevel; // fix casing _options.onlyCompile = _options.contracts; _options.client = _options.client || 'geth'; - embark.initConfig(env || 'development', { - embarkConfig: 'embark.json', - interceptLogs: false - }); embark.build(_options); }); } @@ -128,10 +124,6 @@ class Cmd { .description(__('run dapp (default: %s)', 'development')) .action(function (env, options) { i18n.setOrDetectLocale(options.locale); - embark.initConfig(env || 'development', { - embarkConfig: 'embark.json', - interceptLogs: false - }); embark.run({ env: env || 'development', serverPort: options.port, @@ -221,10 +213,6 @@ class Cmd { _options.logFile = _options.logfile; // fix casing _options.logLevel = _options.loglevel; // fix casing _options.client = _options.client || 'geth'; - embark.initConfig(env || 'development', { - embarkConfig: 'embark.json', - interceptLogs: false - }); embark.upload(_options); }); } @@ -239,10 +227,6 @@ class Cmd { .description(__('generates documentation based on the smart contracts configured')) .action(function (env, options) { i18n.setOrDetectLocale(options.locale); - embark.initConfig(env || 'development', { - embarkConfig: 'embark.json', - interceptLogs: false - }); embark.graph({ env: env || 'development', logFile: options.logfile, diff --git a/lib/cmds/blockchain/blockchain.js b/lib/cmds/blockchain/blockchain.js index bba94c715..cc2d8b1f0 100644 --- a/lib/cmds/blockchain/blockchain.js +++ b/lib/cmds/blockchain/blockchain.js @@ -285,7 +285,8 @@ Blockchain.prototype.initChainAndGetAddress = function(callback) { }); }; -var BlockchainClient = function(blockchainConfig, client, env, isDev, onReadyCallback, onExitCallback) { +var BlockchainClient = function(blockchainConfig, client, env, onReadyCallback, onExitCallback) { + const isDev = blockchainConfig.isDev || blockchainConfig.default; // TODO add other clients at some point if (client === 'geth') { return new Blockchain({blockchainConfig, client: GethCommands, env, isDev, onReadyCallback, onExitCallback}); diff --git a/lib/cmds/blockchain/blockchainProcess.js b/lib/cmds/blockchain/blockchainProcess.js index 013174210..abd879d43 100644 --- a/lib/cmds/blockchain/blockchainProcess.js +++ b/lib/cmds/blockchain/blockchainProcess.js @@ -20,7 +20,6 @@ class BlockchainProcess extends ProcessWrapper { this.blockchainConfig, this.client, this.env, - this.isDev, this.blockchainReady.bind(this), this.blockchainExit.bind(this) ); diff --git a/lib/core/engine.js b/lib/core/engine.js index dd956b697..02ecb919f 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -6,7 +6,6 @@ const IPC = require('./ipc'); class Engine { constructor(options) { this.env = options.env; - this.isDev = options.isDev; this.client = options.client; this.locale = options.locale; this.embarkConfig = options.embarkConfig; @@ -30,6 +29,7 @@ class Engine { this.config = new Config({env: this.env, logger: this.logger, events: this.events, context: this.context}); this.config.loadConfigFiles({embarkConfig: this.embarkConfig, interceptLogs: this.interceptLogs}); this.plugins = this.config.plugins; + this.isDev = this.config && this.config.blockchainConfig && (this.config.blockchainConfig.isDev || this.config.blockchainConfig.default); if (this.interceptLogs || this.interceptLogs === undefined) { this.doInterceptLogs(); diff --git a/lib/index.js b/lib/index.js index 95bca534f..128b4b8f6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -34,13 +34,9 @@ class Embark { this.plugins = this.config.plugins; } - isDev() { - return this.config && this.config.blockchainConfig && (this.config.blockchainConfig.isDev || this.config.blockchainConfig.default); - } - blockchain(env, client) { this.context = [constants.contexts.blockchain]; - return require('./cmds/blockchain/blockchain.js')(this.config.blockchainConfig, client, env, this.isDev()).run(); + return require('./cmds/blockchain/blockchain.js')(this.config.blockchainConfig, client, env).run(); } simulator(options) { @@ -74,7 +70,6 @@ class Embark { env: options.env, client: options.client, locale: options.locale, - isDev: this.isDev(), version: this.version, embarkConfig: options.embarkConfig || 'embark.json', logFile: options.logFile, @@ -168,7 +163,6 @@ class Embark { env: options.env, client: options.client, locale: options.locale, - isDev: this.isDev(), version: this.version, embarkConfig: 'embark.json', interceptLogs: false, @@ -238,7 +232,6 @@ class Embark { const Engine = require('./core/engine.js'); const engine = new Engine({ env: options.env, - isDev: this.isDev(), version: this.version, embarkConfig: options.embarkConfig || 'embark.json', logFile: options.logFile, @@ -293,7 +286,6 @@ class Embark { env: options.env, client: options.client, locale: options.locale, - isDev: this.isDev(), version: this.version, embarkConfig: 'embark.json', interceptLogs: false,