Skip to content

Commit

Permalink
fix: Handle configName lookup for user-specified config files
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Kellen authored and phated committed Nov 22, 2021
1 parent 25ed71b commit f6fd81b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
18 changes: 13 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
10 changes: 8 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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']);
});

});

Expand Down

0 comments on commit f6fd81b

Please sign in to comment.