require-inject
Advanced tools
Comparing version 1.2.1 to 1.3.0
"use strict"; | ||
var path = require("path") | ||
var caller = require('caller'); | ||
@@ -33,4 +34,5 @@ module.exports = function (toLoad, mocks) { | ||
var callerFilename = caller() == module.filename ? caller(2) : caller(); | ||
if (/^[.][.]?\//.test(toLoad)) { | ||
toLoad = path.resolve(path.dirname(module.parent.filename), toLoad) | ||
toLoad = path.resolve(path.dirname(callerFilename), toLoad) | ||
} | ||
@@ -41,5 +43,4 @@ var toLoadPath = require.resolve(toLoad) | ||
delete require.cache[toLoadPath] | ||
// load our new version using our mocks | ||
return module.parent.require(toLoadPath) | ||
return require.cache[callerFilename].require(toLoadPath); | ||
} |
{ | ||
"name": "require-inject", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "A simple mock injector compatible needing no instrumentation in the libraries being tested", | ||
@@ -24,3 +24,6 @@ "main": "index.js", | ||
"tap": "^0.4.13" | ||
}, | ||
"dependencies": { | ||
"caller": "^1.0.1" | ||
} | ||
} |
5522
84
1
+ Addedcaller@^1.0.1
+ Addedcaller@1.1.0(transitive)