require-inject
Advanced tools
Comparing version 1.0.2 to 1.1.0
"use strict"; | ||
var path = require("path") | ||
@@ -10,2 +11,5 @@ module.exports = function (toLoad, mocks) { | ||
if (/^[.][.]?\//.test(toLoad)) { | ||
toLoad = path.resolve(path.dirname(module.parent.filename), toLoad) | ||
} | ||
var toLoadPath = require.resolve(toLoad) | ||
@@ -16,3 +20,3 @@ | ||
// load our new version using our mocks | ||
var mocked = require(toLoadPath) | ||
var mocked = module.parent.require(toLoadPath) | ||
// remove our version from the cache so anyone else gets the real thing | ||
@@ -19,0 +23,0 @@ delete require.cache[toLoadPath] |
{ | ||
"name": "require-inject", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "A simple mock injector compatible needing no instrumentation in the libraries being tested", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
3430
24
3