diff --git a/lib/bootstrap.js b/lib/bootstrap.js index a8c6df0b..1e5e0df3 100644 --- a/lib/bootstrap.js +++ b/lib/bootstrap.js @@ -30,10 +30,8 @@ var log = require('./services/logger').setup({ function getConfig(dir) { dir = path.resolve(dir); - if (dir.indexOf('.', 2) > 0) { - // remove extension - dir = dir.substring(0, dir.indexOf('.', 2)); - } + // remove extension + dir = dir.replace(/.(yaml|yml)/i, ''); if (files.isDirectory(dir)) { // default to bootstrap.yaml or bootstrap.yml @@ -357,3 +355,4 @@ module.exports.bootstrapPath = bootstrapPath; module.exports.setLog = mock => log = mock; module.exports.setDb = mock => db = mock; module.exports.bootstrapSite = bootstrapSite; +module.exports.getConfig = getConfig; diff --git a/lib/bootstrap.test.js b/lib/bootstrap.test.js index c7b9d661..5544583d 100644 --- a/lib/bootstrap.test.js +++ b/lib/bootstrap.test.js @@ -256,4 +256,21 @@ describe(_.startCase(filename), function () { }); }); }); + + describe('getConfig', function () { + const fn = lib[this.title]; + + beforeEach(function () { + sandbox.stub(files, 'getYaml'); + }); + + it('handles file paths that include a dot-delimitted name', function () { + const dir = '/user.name/test/fixtures/config/bootstrap'; + + files.getYaml.returns({}); + + fn(`${dir}.yaml`); + sinon.assert.calledWith(files.getYaml, dir); + }); + }); });