require-in-the-middle
Advanced tools
+9
-3
@@ -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) |
+3
-3
| { | ||
| "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 | ||
| ] | ||
| } |
+8
-3
@@ -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 @@ }) |
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 2 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 2 instances in 1 package
6002
8.38%94
10.59%