From 3e2492e6d47ea4356e00cae56ce63fa363758ff3 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Wed, 20 Apr 2016 11:55:45 -0400 Subject: [PATCH] scaffold: detect incompatible config --- lib/scaffold/start.js | 9 +++++++++ test/scaffold/start.integration.js | 28 ++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/lib/scaffold/start.js b/lib/scaffold/start.js index 47c61307..fa1365dc 100644 --- a/lib/scaffold/start.js +++ b/lib/scaffold/start.js @@ -201,6 +201,15 @@ function start(options) { } fullConfig.path = path.resolve(options.path, './bitcore-node.json'); + + if (fullConfig.datadir) { + throw new TypeError( + 'Configuration file (' + fullConfig.path + ') is not compatible with this version.' + + ' Please see https://github.com/bitpay/bitcore-node/blob/bitcoind/docs/upgrade.md' + + ' for upgrade details.' + ); + } + fullConfig.services = start.setupServices(require, servicesPath, options.config); var node = new BitcoreNode(fullConfig); diff --git a/test/scaffold/start.integration.js b/test/scaffold/start.integration.js index d61f4484..5523f29d 100644 --- a/test/scaffold/start.integration.js +++ b/test/scaffold/start.integration.js @@ -15,7 +15,11 @@ describe('#start', function() { options.services[0].should.deep.equal({ name: 'bitcoind', module: BitcoinService, - config: {} + config: { + spawn: { + datadir: './data' + } + } }); }; TestNode.prototype.start = sinon.stub().callsArg(0); @@ -36,7 +40,13 @@ describe('#start', function() { services: [ 'bitcoind' ], - datadir: './data' + servicesConfig: { + bitcoind: { + spawn: { + datadir: './data' + } + } + } } }); node.should.be.instanceof(TestNode); @@ -59,7 +69,7 @@ describe('#start', function() { path: __dirname, config: { services: [], - datadir: './testdir' + servicesConfig: {} } }); setImmediate(function() { @@ -74,7 +84,10 @@ describe('#start', function() { name: 'bitcoind', module: BitcoinService, config: { - param: 'test' + param: 'test', + spawn: { + datadir: './data' + } } }); }; @@ -97,10 +110,13 @@ describe('#start', function() { ], servicesConfig: { 'bitcoind': { - param: 'test' + param: 'test', + spawn: { + datadir: './data' + } } }, - datadir: './data' + } }); node.should.be.instanceof(TestNode);