require-in-the-middle
Advanced tools
Comparing version 2.0.3 to 2.1.0
12
index.js
@@ -13,4 +13,10 @@ 'use strict' | ||
var patched = {} | ||
if (typeof Module._resolveFilename !== 'function') { | ||
console.error('Error: Expected Module._resolveFilename to be a function (was: %s) - aborting!', typeof Module._resolveFilename) | ||
console.error('Please report this error as an issue related to Node.js %s at %s', process.version, require('./package.json').bugs.url) | ||
return | ||
} | ||
hook.cache = {} | ||
Module._load = function (request, parent, isMain) { | ||
@@ -43,4 +49,4 @@ var exports = orig.apply(Module, arguments) | ||
if (patched[filename]) return exports // abort if module have already been processed | ||
patched[filename] = true | ||
if (hook.cache[filename]) return exports // abort if module have already been processed | ||
hook.cache[filename] = exports | ||
@@ -47,0 +53,0 @@ return onrequire(exports, name, basedir) |
{ | ||
"name": "require-in-the-middle", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "Module to hook into the Node.js require function", | ||
@@ -43,5 +43,5 @@ "main": "index.js", | ||
"coordinates": [ | ||
55.6665906, | ||
12.580154 | ||
55.6665607, | ||
12.5801843 | ||
] | ||
} |
11
test.js
@@ -7,3 +7,3 @@ 'use strict' | ||
test('all modules', function (t) { | ||
t.plan(6) | ||
t.plan(8) | ||
@@ -29,5 +29,10 @@ var n = 1 | ||
var http = require('http') | ||
var net = require('net') | ||
t.equal(http.foo, 1) | ||
t.equal(net.foo, 2) | ||
t.equal(require('http').foo, 1) | ||
t.equal(require('net').foo, 2) | ||
t.equal(require('http').foo, 1) | ||
t.deepEqual(hook.cache['http'], http) | ||
t.deepEqual(hook.cache['net'], net) | ||
t.equal(n, 3) | ||
@@ -34,0 +39,0 @@ }) |
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
6002
94