proxyquire
Advanced tools
Comparing version 1.7.10 to 1.7.11
@@ -223,4 +223,21 @@ 'use strict'; | ||
for (var id in cache) { | ||
// Keep native modules (i.e. `.node` files). | ||
// Otherwise, Node.js would throw a “Module did not self-register” | ||
// error upon requiring it a second time. | ||
// See https://github.com/nodejs/node/issues/5016. | ||
if (/\.node$/.test(id)) { | ||
require.cache[id] = cache[id]; | ||
} | ||
} | ||
// Return a function that will undo what we just did | ||
return function() { | ||
// Keep native modules which were added to the cache in the meantime. | ||
for (var id in require.cache) { | ||
if (/\.node$/.test(id)) { | ||
cache[id] = require.cache[id] | ||
} | ||
} | ||
require.cache = Module._cache = cache; | ||
@@ -227,0 +244,0 @@ }; |
{ | ||
"name": "proxyquire", | ||
"version": "1.7.10", | ||
"version": "1.7.11", | ||
"description": "Proxies nodejs require in order to allow overriding dependencies during testing.", | ||
@@ -27,3 +27,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mocha": "~1.18", | ||
"mocha": "~3.1", | ||
"native-hello-world": "^1.0.0", | ||
"should": "~3.3", | ||
@@ -30,0 +31,0 @@ "sinon": "~1.9" |
@@ -42,2 +42,13 @@ /*jshint asi:true*/ | ||
}); | ||
it('should not throw when a native module is required a second time', function () { | ||
var stubs = { | ||
'foo': { | ||
'@global': true | ||
} | ||
}; | ||
proxyquire('native-hello-world', stubs) | ||
proxyquire('native-hello-world', stubs) | ||
}) | ||
}); | ||
@@ -44,0 +55,0 @@ |
Sorry, the diff of this file is not supported yet
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
61860
1307
4