Skip to content

Commit

Permalink
Allow config path to be configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanspears committed Oct 14, 2016
1 parent 521c96f commit 6a643e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ function createHandlers(options) {
return result;
}

function configPath(prefix) {
return path.join(prefix, 'config');
function configPath(prefix, configdir) {
configdir = (configdir) ? configdir : 'config';
return path.join(prefix, configdir);
}


Expand All @@ -56,7 +57,7 @@ exports.create = function create(options) {
appProtocols = createHandlers(options);
baseProtocols = createHandlers(options);

appProtocols.resolve = ssresolve(configPath(options.basedir));
appProtocols.resolve = ssresolve(configPath(options.basedir, options.configdir));
baseProtocols.resolve = ssresolve(configPath(path.dirname(__dirname)));

baseFactory = confit({ basedir: configPath(path.dirname(__dirname)), protocols: baseProtocols });
Expand All @@ -67,7 +68,7 @@ exports.create = function create(options) {
}

appFactory = confit({
basedir: configPath(options.basedir),
basedir: configPath(options.basedir, options.configdir),
protocols: appProtocols
});
appFactory.create(function(err, appConf) {
Expand Down
18 changes: 18 additions & 0 deletions test/kraken.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ test('kraken', function (t) {
app.use(kraken({ basedir: __dirname }));
});

t.test('startup with custom config directory', function (t) {
var app;

t.plan(1);

function start() {
t.pass('server started');
}

function error(err) {
t.error(err, 'server startup failed');
}

app = express();
app.on('start', start);
app.on('error', error);
app.use(kraken({ configdir: 'config' }));
});

t.test('mount point', function (t) {
var options, app, server;
Expand Down

0 comments on commit 6a643e5

Please sign in to comment.