Skip to content

Commit 478fd55

Browse files
Tyler Kellenphated
authored andcommitted
New: Add module name to return when prepare is successful
1 parent 2ba8b29 commit 478fd55

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ exports.prepare = function (extensions, filepath, cwd) {
2727
option = config[i];
2828
attempt = register(cwd, option.module, option.register);
2929
error = (attempt instanceof Error) ? attempt : null;
30+
if (error) {
31+
attempt = null;
32+
}
3033
attempts.push({
31-
module: option.module,
34+
moduleName: option.module,
35+
module: attempt,
3236
error: error
3337
});
3438
if (!error) {

test/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ describe('rechoir', function () {
5656
} catch (e) {
5757
expect(e.failures).to.be.array;
5858
expect(e.failures[0].error).to.be.instanceof(Error);
59-
expect(e.failures[0].module).to.equal('nothere');
59+
expect(e.failures[0].moduleName).to.equal('nothere');
60+
expect(e.failures[0].module).to.be.null;
6061
expect(e.failures[1].error).to.be.instanceof(Error);
61-
expect(e.failures[1].module).to.equal('orhere');
62+
expect(e.failures[1].moduleName).to.equal('orhere');
63+
expect(e.failures[1].module).to.be.null;
6264
}
6365
});
6466

test/lib/register.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ describe('register', function () {
1010
});
1111

1212
it('should call a register function if provided, passing in the module', function () {
13-
register(__dirname, 'chai', function (module) {
14-
expect(module).to.equal(chai);
13+
register(__dirname, 'chai', function (attempt) {
14+
expect(attempt).to.equal(chai);
1515
});
1616
});
1717

0 commit comments

Comments
 (0)