Skip to content

Commit

Permalink
add specificity to bootstrap yaml execution (#682)
Browse files Browse the repository at this point in the history
* add specificity to bootstrap yaml execution

* Update lib/bootstrap.js

* oopsie

* rm log
  • Loading branch information
reubenson authored and jpope19 committed Dec 10, 2019
1 parent 270e29d commit c115e17
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
17 changes: 17 additions & 0 deletions lib/bootstrap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

0 comments on commit c115e17

Please sign in to comment.