@@ -21,6 +21,7 @@ process.on('SIGPIPE', () => {
21
21
//#endregion
22
22
23
23
//#region Add support for redirecting the loading of node modules
24
+
24
25
exports . injectNodeModuleLookupPath = function ( injectPath ) {
25
26
if ( ! injectPath ) {
26
27
throw new Error ( 'Missing injectPath' ) ;
@@ -36,18 +37,16 @@ exports.injectNodeModuleLookupPath = function (injectPath) {
36
37
const originalResolveLookupPaths = Module . _resolveLookupPaths ;
37
38
38
39
// @ts -ignore
39
- Module . _resolveLookupPaths = function ( moduleName , parent , newReturn ) {
40
- const result = originalResolveLookupPaths ( moduleName , parent , newReturn ) ;
41
-
42
- const paths = newReturn ? result : result [ 1 ] ;
40
+ Module . _resolveLookupPaths = function ( moduleName , parent ) {
41
+ const paths = originalResolveLookupPaths ( moduleName , parent ) ;
43
42
for ( let i = 0 , len = paths . length ; i < len ; i ++ ) {
44
43
if ( paths [ i ] === nodeModulesPath ) {
45
44
paths . splice ( i , 0 , injectPath ) ;
46
45
break ;
47
46
}
48
47
}
49
48
50
- return result ;
49
+ return paths ;
51
50
} ;
52
51
} ;
53
52
//#endregion
@@ -71,19 +70,18 @@ exports.enableASARSupport = function (nodeModulesPath) {
71
70
72
71
// @ts -ignore
73
72
const originalResolveLookupPaths = Module . _resolveLookupPaths ;
74
- // @ts -ignore
75
- Module . _resolveLookupPaths = function ( request , parent , newReturn ) {
76
- const result = originalResolveLookupPaths ( request , parent , newReturn ) ;
77
73
78
- const paths = newReturn ? result : result [ 1 ] ;
74
+ // @ts -ignore
75
+ Module . _resolveLookupPaths = function ( request , parent ) {
76
+ const paths = originalResolveLookupPaths ( request , parent ) ;
79
77
for ( let i = 0 , len = paths . length ; i < len ; i ++ ) {
80
78
if ( paths [ i ] === NODE_MODULES_PATH ) {
81
79
paths . splice ( i , 0 , NODE_MODULES_ASAR_PATH ) ;
82
80
break ;
83
81
}
84
82
}
85
83
86
- return result ;
84
+ return paths ;
87
85
} ;
88
86
} ;
89
87
//#endregion
0 commit comments