Skip to content

Commit

Permalink
New: Add module name to return when prepare is successful
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Kellen authored and phated committed Jan 4, 2019
1 parent 2ba8b29 commit 478fd55
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion index.js
Expand Up @@ -27,8 +27,12 @@ exports.prepare = function (extensions, filepath, cwd) {
option = config[i];
attempt = register(cwd, option.module, option.register);
error = (attempt instanceof Error) ? attempt : null;
if (error) {
attempt = null;
}
attempts.push({
module: option.module,
moduleName: option.module,
module: attempt,
error: error
});
if (!error) {
Expand Down
6 changes: 4 additions & 2 deletions test/index.js
Expand Up @@ -56,9 +56,11 @@ describe('rechoir', function () {
} catch (e) {
expect(e.failures).to.be.array;
expect(e.failures[0].error).to.be.instanceof(Error);
expect(e.failures[0].module).to.equal('nothere');
expect(e.failures[0].moduleName).to.equal('nothere');
expect(e.failures[0].module).to.be.null;
expect(e.failures[1].error).to.be.instanceof(Error);
expect(e.failures[1].module).to.equal('orhere');
expect(e.failures[1].moduleName).to.equal('orhere');
expect(e.failures[1].module).to.be.null;
}
});

Expand Down
4 changes: 2 additions & 2 deletions test/lib/register.js
Expand Up @@ -10,8 +10,8 @@ describe('register', function () {
});

it('should call a register function if provided, passing in the module', function () {
register(__dirname, 'chai', function (module) {
expect(module).to.equal(chai);
register(__dirname, 'chai', function (attempt) {
expect(attempt).to.equal(chai);
});
});

Expand Down

0 comments on commit 478fd55

Please sign in to comment.