From f6fd81b64fd7dd76ab2f3b53cd763bbdb5ac9b83 Mon Sep 17 00:00:00 2001 From: Tyler Kellen Date: Mon, 22 Dec 2014 10:12:32 -0500 Subject: [PATCH] fix: Handle configName lookup for user-specified config files --- index.js | 18 +++++++++++++----- test/index.js | 10 ++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 5c8d4b1..3f1e4f3 100644 --- a/index.js +++ b/index.js @@ -55,11 +55,19 @@ Liftoff.prototype.buildEnvironment = function (opts) { searchPaths.unshift(cwd); } - // calculate the regex to use for finding the config file - var configNameSearch = buildConfigName({ - configName: this.configName, - extensions: Object.keys(this.extensions) - }); + // a list of possible configuration names + var configNameSearch; + + if (opts.configName) { + // if a configName has been provided by the user, only look for that + configNameSearch = [opts.configName]; + } else { + // otherwise, look for the default configName using all available extensions + configNameSearch = buildConfigName({ + configName: this.configName, + extensions: Object.keys(this.extensions) + }); + } // calculate configPath var configPath = findConfig({ diff --git a/test/index.js b/test/index.js index 3eee1e5..437ad68 100644 --- a/test/index.js +++ b/test/index.js @@ -90,7 +90,6 @@ describe('Liftoff', function () { expect(app.buildEnvironment().cwd).to.equal(path.resolve('test/fixtures/search_path')); }); - it('should resolve symlinks if config is one', function () { var env = app.buildEnvironment({ cwd: 'test/fixtures/symlink' @@ -103,7 +102,14 @@ describe('Liftoff', function () { configPath: 'test/fixtures/symlink/mochafile.js' }); expect(env.cwd).to.equal(path.resolve('test/fixtures/symlink')); - }) + }); + + it('should be able to find custom configuration file names', function () { + var env = app.buildEnvironment({ + configName: 'myconfig.js' + }); + expect(env.configNameSearch).to.deep.equal(['myconfig.js']); + }); });