Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Commit

Permalink
[GB] check installed deps & log user friendly error, fix #2455
Browse files Browse the repository at this point in the history
  • Loading branch information
askmike committed Aug 20, 2018
1 parent de8cfa7 commit 8d9ae8c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/tools/dataStitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Stitcher.prototype.ago = function(ts) {
}

Stitcher.prototype.verifyExchange = function() {
require(dirs.gekko + 'exchange/dependencyCheck');
const exchangeChecker = require(dirs.gekko + 'exchange/exchangeChecker');
const slug = config.watch.exchange.toLowerCase();
let exchange;
Expand Down
23 changes: 23 additions & 0 deletions exchange/dependencyCheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const deps = require('./package.json').dependencies;

const missing = [];

Object.keys(deps).forEach(dep => {
try {
require(dep);
} catch(e) {
if(e.code === 'MODULE_NOT_FOUND') {
missing.push(dep);
}
}
});

if(missing.length) {
console.error(
'\nThe following Gekko Broker dependencies are not installed: [',
missing.join(', '),
'].\n\nYou need to install them first, read here how:',
'https://gekko.wizb.it/docs/installation/installing_gekko.html#Installing-Gekko-39-s-dependencies\n'
);
process.exit(1);
}
2 changes: 2 additions & 0 deletions plugins/trader/trader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const moment = require('moment');
const log = require(dirs.core + 'log');
const Broker = require(dirs.gekko + '/exchange/gekkoBroker');

require(dirs.gekko + '/exchange/dependencyCheck');

const Trader = function(next) {

_.bindAll(this);
Expand Down

0 comments on commit 8d9ae8c

Please sign in to comment.