@@ -17,7 +17,7 @@ function restoreOriginalWrappers() {
1717/**
1818 * Does actual rewiring the module. For further documentation @see index.js
1919 */
20- function rewire ( parentModule , filename , cache ) {
20+ function rewire ( parentModulePath , targetPath , cache ) {
2121var testModule ,
2222nodeRequire ,
2323prepend ,
@@ -37,21 +37,21 @@ function rewire(parentModule, filename, cache) {
3737}
3838
3939// Checking params
40- if ( typeof filename !== "string" ) {
40+ if ( typeof targetPath !== "string" ) {
4141throw new TypeError ( "Filename must be a string" ) ;
4242}
4343
4444// Resolve full filename relative to the parent module
45- filename = Module . _resolveFilename ( filename , parentModule ) ;
45+ targetPath = Module . _resolveFilename ( targetPath , parentModulePath ) ;
4646
4747// Special support for older node versions that returned an array on Module._resolveFilename
4848//@see https://github.com/joyent/node/blob/865b077819a9271a29f982faaef99dc635b57fbc/lib/module.js#L319
49- if ( Array . isArray ( filename ) ) {
50- filename = filename [ 1 ] ;
49+ if ( Array . isArray ( targetPath ) ) {
50+ targetPath = targetPath [ 1 ] ;
5151}
5252
5353// Create testModule as it would be created by require()
54- testModule = new Module ( filename , parentModule ) ;
54+ testModule = new Module ( targetPath , parentModulePath ) ;
5555
5656// Patching requireProxy
5757nodeRequire = testModule . require ;
@@ -66,7 +66,7 @@ function rewire(parentModule, filename, cache) {
6666
6767// Check if the module uses the strict mode.
6868// If so we must ensure that "use strict"; stays at the beginning of the module.
69- src = fs . readFileSync ( filename , "utf8" ) ;
69+ src = fs . readFileSync ( targetPath , "utf8" ) ;
7070if ( detectStrictMode ( src ) === true ) {
7171prepend = ' "use strict"; ' + prepend ;
7272}
@@ -82,8 +82,8 @@ function rewire(parentModule, filename, cache) {
8282
8383// Store the rewired module in the cache when enabled
8484if ( cache ) {
85- rewiredModules . push ( filename ) ; // save in private cache for .reset()
86- require . cache [ filename ] = testModule ;
85+ rewiredModules . push ( targetPath ) ; // save in private cache for .reset()
86+ require . cache [ targetPath ] = testModule ;
8787}
8888
8989// This is only necessary if nothing has been required within the module