Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

rewire

Package Overview
Dependencies
117
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.1 to 5.0.0

.history/.travis_20180410004832.yml

4

CHANGELOG.md
Changelog
---------
### 5.0.0
- **Breaking**: Remove Node v6 support. We had to do this because one of our dependencies had security issues and the version with the fix dropped Node v6 as well.
- Update dependencies [#159](https://github.com/jhnns/rewire/pull/159) [#172](https://github.com/jhnns/rewire/issues/172) [#154](https://github.com/jhnns/rewire/issues/154) [#166](https://github.com/jhnns/rewire/issues/166)
### 4.0.1

@@ -5,0 +9,0 @@ - Fix a bug where `const` was not properly detected [#139](https://github.com/jhnns/rewire/pull/139)

2

lib/moduleEnv.js

@@ -45,3 +45,3 @@ "use strict";

// Test the regular expresssion at https://regex101.com/r/dvnZPv/2 and also check out testLib/constModule.js.
matchConst = /(^|\s|\}|;)const(\/\*|\s)/gm,
matchConst = /(^|\s|\}|;)const(\/\*|\s|{)/gm,
nodeRequire,

@@ -48,0 +48,0 @@ currentModule;

{
"name": "rewire",
"version": "4.0.1",
"version": "5.0.0",
"description": "Easy dependency injection for node.js unit testing",

@@ -35,3 +35,4 @@ "keywords": [

"expect.js": "^0.3.1",
"mocha": "^4.0.1"
"mocha": "^7.1.0",
"rewire": "file://."
},

@@ -44,4 +45,4 @@ "license": "MIT",

"dependencies": {
"eslint": "^4.19.1"
"eslint": "^6.8.0"
}
}

@@ -34,3 +34,3 @@ rewire

```javascript
// lib/myModules.js
// lib/myModule.js
// With rewire you can change all these variables

@@ -37,0 +37,0 @@ var fs = require("fs"),

@@ -12,2 +12,3 @@ const j = "j"; // At the beginning of the file

const /*and this is also*/i = "i";
const{k} = {k: "k"};

@@ -44,1 +45,4 @@ exports.a = function () {

};
exports.k = function () {
return k;
};
{
"main": "../../../lib/index.js"
}

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

it("should provide the ability to mock global objects just within the module", function () {
// This test fails on modern Node versions since they started to configure some
// global variables to be non-enumerable. This means that rewire() does in fact
// modify the global console object in newer Node versions.
// There is a work in progress fix at https://github.com/jhnns/rewire/tree/fix-globals
it.skip("should provide the ability to mock global objects just within the module", function () {
var rewiredModuleA = rewire("./moduleA.js"),

@@ -392,6 +396,9 @@ rewiredModuleB = rewire("./moduleB.js"),

var constModule = rewire("./constModule");
var varNames = Object.keys(constModule);
"abcdefghij".split("").forEach(letter => {
constModule.__set__(letter, "this has been changed"); // should not throw
expect(constModule[letter]()).to.equal("this has been changed");
expect(varNames.length).to.be.greaterThan(0);
varNames.forEach(varName => {
constModule.__set__(varName, "this has been changed"); // should not throw
expect(constModule[varName]()).to.equal("this has been changed");
});

@@ -398,0 +405,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc