From 478fd5518270dbcc96900a182fb4a98d76819a1e Mon Sep 17 00:00:00 2001 From: Tyler Kellen Date: Wed, 20 May 2015 20:30:03 -0400 Subject: [PATCH] New: Add module name to return when prepare is successful --- index.js | 6 +++++- test/index.js | 6 ++++-- test/lib/register.js | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index fc57712..8cb5be9 100644 --- a/index.js +++ b/index.js @@ -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) { diff --git a/test/index.js b/test/index.js index 4ecc6a9..212e3c9 100644 --- a/test/index.js +++ b/test/index.js @@ -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; } }); diff --git a/test/lib/register.js b/test/lib/register.js index 6bba5fe..c02c92e 100644 --- a/test/lib/register.js +++ b/test/lib/register.js @@ -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); }); });