Skip to content

Commit

Permalink
feat: Add support for compound extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
mmotorny authored and phated committed Nov 22, 2021
1 parent aa282b7 commit 639867e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ Liftoff.prototype.buildEnvironment = function (opts) {
}
}

// get extension of config name, taking anything after the -first- dot
var configExtension = /(\.[^\/]*)?$/.exec(configPath)[0];

// preload module needed for config if any has been specified.
var requireForExtension = this.extensions[path.extname(configPath)];
var requireForExtension = this.extensions[configExtension];
if (requireForExtension) {
preload.push(requireForExtension);
}
Expand Down
Empty file.
10 changes: 9 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ var app = new Liftoff({
extensions: {
'.js': null,
'.json': null,
'.coffee': 'coffee-script/register'
'.coffee': 'coffee-script/register',
'.coffee.md': 'coffee-script/register',
},
searchPaths: ['test/fixtures/search_path']
});
Expand Down Expand Up @@ -52,6 +53,13 @@ describe('Liftoff', function () {
expect(name).to.equal('coffee-script/register');
expect(mod).to.equal(require('coffee-script/register'));
expect(env.require).to.deep.equal(['coffee-script/register']);
// testing compound extension
env = app.buildEnvironment({
configPath: 'test/fixtures/coffee/mochafile.coffee.md'
});
expect(name).to.equal('coffee-script/register');
expect(mod).to.equal(require('coffee-script/register'));
expect(env.require).to.deep.equal(['coffee-script/register']);
});

it('should locate local module using cwd if no config is found', function () {
Expand Down

0 comments on commit 639867e

Please sign in to comment.