Socket
Socket
Sign inDemoInstall

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.0.0 to 2.0.1

.istanbul.yml

24

CHANGELOG.md
##Changelog
###v2.0.0
###2.0.1
- Added test coverage tool
- Small README and description changes
###2.0.0
- Removed client-side bundler extensions. Browserify is not supported anymore. Webpack support has been extracted
into separate repository https://github.com/jhnns/rewire-webpack
###v1.1.3
###1.1.3
- Removed IDE stuff from npm package
###v1.1.2
###1.1.2
- Added deprecation warning for client-side bundlers
- Updated package.json for node v0.10
###v1.1.1
###1.1.1
- Fixed bug with modules that had a comment on the last line
###v1.1.0
###1.1.0
- Added Coffee-Script support
- Removed Makefile: Use `npm test` instead.
###v1.0.4
###1.0.4
- Improved client-side rewire() with webpack
###v1.0.3
###1.0.3
- Fixed error with client-side bundlers when a module was ending with a comment
###v1.0.2
###1.0.2
- Improved strict mode detection
###v1.0.1
###1.0.1
- Fixed crash when a global module has been used in the browser
###v1.0.0
###1.0.0
- Removed caching functionality. Now rewire doesn't modify `require.cache` at all

@@ -35,0 +39,0 @@ - Added support for [webpack](https://github.com/webpack/webpack)-bundler

@@ -0,0 +0,0 @@ /**

@@ -17,11 +17,13 @@ /**

ignore = ignore || [];
// global itself can't be overridden because it's the only reference to our real global objects
ignore.push("global");
for (key in globalObj) {
if (key !== "global" && ignore.indexOf(key) === -1) { // we don't use hasOwnProperty here because in some browsers not all global objects will be enumerated
value = globalObj[key];
src += "var " + key + " = global." + key + "; ";
for (key in globalObj) { /* jshint forin: false */
if (ignore.indexOf(key) !== -1) {
continue;
}
value = globalObj[key];
src += "var " + key + " = global." + key + "; ";
}
return src;

@@ -28,0 +30,0 @@ }

@@ -0,0 +0,0 @@ var rewireModule = require("./rewire.js");

@@ -0,0 +0,0 @@ "use strict";

@@ -9,2 +9,5 @@ var Module = require("module"),

var __get__Src = __get__.toString(),
__set__Src = __set__.toString();
/**

@@ -30,2 +33,3 @@ * Does actual rewiring the module. For further documentation @see index.js

// TODO Remove this switch on the next major release
/* istanbul ignore next because it will be removed soon */
if (Array.isArray(targetPath)) {

@@ -43,4 +47,4 @@ targetPath = targetPath[1];

appendix = "\n";
appendix += "module.exports.__set__ = " + __set__.toString() + "; ";
appendix += "module.exports.__get__ = " + __get__.toString() + "; ";
appendix += "module.exports.__set__ = " + __set__Src + "; ";
appendix += "module.exports.__get__ = " + __get__Src + "; ";

@@ -47,0 +51,0 @@ // Check if the module uses the strict mode.

{
"name" : "rewire",
"version" : "2.0.0",
"description" : "Dependency injection for node.js applications",
"version" : "2.0.1",
"description" : "Easy dependency injection for node.js unit testing",
"keywords" : [

@@ -30,5 +30,2 @@ "dependency",

},
"engines" : {
"node" : "<0.12.x"
},
"devDependencies": {

@@ -40,4 +37,5 @@ "mocha": "1.x",

"scripts" : {
"test" : "node node_modules/mocha/bin/mocha -R spec"
"test" : "node node_modules/mocha/bin/mocha -R spec",
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha"
}
}
rewire
=====
**Dependency injection for node.js applications**.
**Easy dependency injection for node.js unit testing**.

@@ -20,4 +20,5 @@ rewire adds a special setter and getter to modules so you can modify their behaviour for better unit testing. You may

[![Build Status](https://secure.travis-ci.org/jhnns/rewire.png?branch=master)](http://travis-ci.org/jhnns/rewire)
[![Dependency Status](https://david-dm.org/jhnns/rewire/status.png)](http://david-dm.org/jhnns/rewire)
[![Build Status](https://travis-ci.org/jhnns/rewire.svg?branch=master)](http://travis-ci.org/jhnns/rewire)
[![Dependency Status](https://david-dm.org/jhnns/rewire.svg)](https://david-dm.org/jhnns/rewire)
[![Coverage Status](https://img.shields.io/coveralls/jhnns/rewire.svg)](https://coveralls.io/r/jhnns/rewire)

@@ -24,0 +25,0 @@ <br />

@@ -0,0 +0,0 @@ var expect = require("expect.js"),

@@ -0,0 +0,0 @@ var expect = require("expect.js"),

@@ -0,0 +0,0 @@ var expect = require("expect.js"),

@@ -16,3 +16,8 @@ var expect = require("expect.js"),

vm.runInNewContext(src, context);
actualGlobals = Object.keys(context);
actualGlobals = Object.keys(context).filter(function (key) {
// node v0.10 does not set a constructor property on the context
// node v0.11 does set a constructor property
// so just lets filter it, because it doesn't make sense to mock it anyway
return key !== "constructor";
});
actualGlobals.sort();

@@ -32,3 +37,4 @@ expectedGlobals.sort();

src = getImportGlobalsSrc(ignore);
// getImportGlobalsSrc modifies the ignore array, so let's create a copy
src = getImportGlobalsSrc(ignore.slice(0));
expectedGlobals = expectedGlobals.filter(function filterIgnoredVars(value) {

@@ -38,3 +44,8 @@ return ignore.indexOf(value) === -1;

vm.runInNewContext(src, context);
actualGlobals = Object.keys(context);
actualGlobals = Object.keys(context).filter(function (key) {
// node v0.10 does not set a constructor property on the context
// node v0.11 does set a constructor property
// so just lets filter it, because it doesn't make sense to mock it anyway
return key !== "constructor";
});
actualGlobals.sort();

@@ -41,0 +52,0 @@ expectedGlobals.sort();

@@ -0,0 +0,0 @@ // Don't run code in ES5 strict mode.

@@ -0,0 +0,0 @@ "use strict"; // run code in ES5 strict mode

@@ -0,0 +0,0 @@ "use strict"; // run code in ES5 strict mode

@@ -178,2 +178,7 @@ // Don't run code in ES5 strict mode.

});
it("should throw a TypeError if the path is not a string", function () {
expect(function () {
rewire(null);
}).to.throwException(checkForTypeError);
});
});

@@ -0,0 +0,0 @@ "use strict"; // run code in ES5 strict mode

module.exports = function () {
throw new Error();
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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