Comparing version 2.1.2 to 2.1.3
@@ -19,2 +19,6 @@ /** | ||
ignore.push("global"); | ||
// ignore 'module', 'exports' and 'require' on the global scope, because otherwise our code would | ||
// shadow the module-internal variables | ||
// @see https://github.com/jhnns/rewire-webpack/pull/6 | ||
ignore.push("module", "exports", "require"); | ||
@@ -21,0 +25,0 @@ for (key in globalObj) { /* jshint forin: false */ |
var Module = require("module"), | ||
fs = require("fs"), | ||
__get__ = require("./__get__.js"), | ||
__set__ = require ("./__set__.js"), | ||
__with__ = require("./__with__.js"), | ||
getImportGlobalsSrc = require("./getImportGlobalsSrc.js"), | ||
getDefinePropertySrc = require("./getDefinePropertySrc.js"), | ||
detectStrictMode = require("./detectStrictMode.js"), | ||
moduleEnv = require("./moduleEnv.js"); | ||
var srcs = { | ||
"__get__": __get__.toString(), | ||
"__set__": __set__.toString(), | ||
"__with__": __with__.toString() | ||
}; | ||
/** | ||
@@ -48,11 +40,3 @@ * Does actual rewiring the module. For further documentation @see index.js | ||
// We append our special setter and getter. | ||
appendix = "\n"; | ||
Object.keys(srcs).forEach(function forEachSrc(key) { | ||
appendix += "Object.defineProperty(module.exports, '" + | ||
key + | ||
"', {enumerable: false, value: " + | ||
srcs[key] + | ||
"}); "; | ||
}); | ||
appendix = "\n" + getDefinePropertySrc(); | ||
@@ -59,0 +43,0 @@ // Check if the module uses the strict mode. |
{ | ||
"name" : "rewire", | ||
"version" : "2.1.2", | ||
"version" : "2.1.3", | ||
"description" : "Easy dependency injection for node.js unit testing", | ||
@@ -5,0 +5,0 @@ "keywords" : [ |
@@ -10,7 +10,20 @@ var expect = require("expect.js"), | ||
}, | ||
expectedGlobals, | ||
src, | ||
actualGlobals, | ||
expectedGlobals = Object.keys(global); | ||
actualGlobals; | ||
// Temporarily set module-internal variables on the global scope to check if getImportGlobalsSrc() | ||
// ignores them properly | ||
global.module = module; | ||
global.exports = exports; | ||
global.require = require; | ||
src = getImportGlobalsSrc(); | ||
delete global.module; | ||
delete global.exports; | ||
delete global.require; | ||
expectedGlobals = Object.keys(global); | ||
vm.runInNewContext(src, context); | ||
@@ -17,0 +30,0 @@ actualGlobals = Object.keys(context).filter(function (key) { |
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
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
61558
34
1210
10