diff --git a/bin/embark b/bin/embark index 19916959..c3661708 100755 --- a/bin/embark +++ b/bin/embark @@ -10,26 +10,6 @@ try { } } -function launchEmbark() { - var Cmd = require('../cmd/cmd'); - var cli = new Cmd(); - cli.process(process.argv); -} - -const path = require('path'); -try { - const dappPackage = require(path.join(process.cwd(), 'package.json')); - require(path.join(process.cwd(), 'embark.json')); // Make sure we are in a Dapp - require('check-dependencies')(dappPackage, (state) => { - if (state.status) { - require('colors'); - console.error('\nMissing dependencies. Please run npm install'.red); - process.exit(); - } - launchEmbark(); - }); -} catch (_e) { - // We are not in a Dapp - launchEmbark(); -} - +var Cmd = require('../cmd/cmd'); +var cli = new Cmd(); +cli.process(process.argv); diff --git a/cmd/cmd.js b/cmd/cmd.js index d7d2876d..1e1cb9a9 100644 --- a/cmd/cmd.js +++ b/cmd/cmd.js @@ -30,6 +30,25 @@ process.env.NODE_PATH = utils.joinPath(process.env.EMBARK_PATH, 'node_modules') (process.env.NODE_PATH ? require('path').delimiter : '') + (process.env.NODE_PATH || ''); +function checkDeps() { + const path = require('path'); + try { + const dappPackage = require(path.join(process.cwd(), 'package.json')); + require(path.join(process.cwd(), 'embark.json')); // Make sure we are in a Dapp + require('check-dependencies')(dappPackage, (state) => { + if (state.status) { + require('colors'); + console.error('\nMissing dependencies. Please run npm install'.red); + process.exit(); + } + return true; + }); + } catch (_e) { + // We are not in a Dapp + return true; + } +} + class Cmd { constructor() { program.version(embark.version); @@ -129,6 +148,7 @@ class Cmd { .option('--pipeline [pipeline]', __('webpack config to use (default: production)')) .description(__('deploy and build dapp at ') + 'dist/ (default: development)') .action(function(env, _options) { + checkDeps(); i18n.setOrDetectLocale(_options.locale); _options.env = env || 'development'; _options.logFile = _options.logfile; // fix casing @@ -155,6 +175,7 @@ class Cmd { .option('--pipeline [pipeline]', __('webpack config to use (default: development)')) .description(__('run dapp (default: %s)', 'development')) .action(function(env, options) { + checkDeps(); i18n.setOrDetectLocale(options.locale); embark.run({ env: env || 'development', @@ -181,6 +202,7 @@ class Cmd { .option('--pipeline [pipeline]', __('webpack config to use (default: development)')) .description(__('Start the Embark console')) .action(function(env, options) { + checkDeps(); i18n.setOrDetectLocale(options.locale); embark.console({ env: env || 'development', @@ -200,6 +222,7 @@ class Cmd { .option('--locale [locale]', __('language to use (default: en)')) .description(__('run blockchain server (default: %s)', 'development')) .action(function(env, options) { + checkDeps(); i18n.setOrDetectLocale(options.locale); embark.initConfig(env || 'development', { embarkConfig: 'embark.json', @@ -222,6 +245,7 @@ class Cmd { .option('--locale [locale]', __('language to use (default: en)')) .action(function(env, options) { + checkDeps(); i18n.setOrDetectLocale(options.locale); embark.initConfig(env || 'development', { embarkConfig: 'embark.json', @@ -246,6 +270,7 @@ class Cmd { .option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'warn') .description(__('run tests')) .action(function(file, options) { + checkDeps(); i18n.setOrDetectLocale(options.locale); embark.runTests({file, loglevel: options.loglevel, gasDetails: options.gasDetails, node: options.node}); }); @@ -262,6 +287,7 @@ class Cmd { .option('--pipeline [pipeline]', __('webpack config to use (default: production)')) .description(__('Upload your dapp to a decentralized storage') + '.') .action(function(env, _options) { + checkDeps(); i18n.setOrDetectLocale(_options.locale); if (env === "ipfs" || env === "swarm") { console.warn(("did you mean " + "embark upload".bold + " ?").underline); @@ -286,6 +312,7 @@ class Cmd { .option('--locale [locale]', __('language to use (default: en)')) .description(__('generates documentation based on the smart contracts configured')) .action(function(env, options) { + checkDeps(); i18n.setOrDetectLocale(options.locale); embark.graph({ env: env || 'development',