Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rewire

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rewire - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

lib/getDefinePropertySrc.js

4

lib/getImportGlobalsSrc.js

@@ -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 */

20

lib/rewire.js
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) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc