@@ -83,34 +83,30 @@ export function retryAsync(fn: () => Promise<any>, timeoutMs: number): Promise<a
83
83
}
84
84
85
85
function tryFindSourcePathInNSProject ( nsProjectPath : string , additionalFileExtension : string , resorcePath : string ) : string {
86
- let guesses = [ ] ;
86
+ let guess : string = "" ;
87
87
const pathParts = resorcePath . split ( path . sep ) ;
88
88
let appIndex = pathParts . indexOf ( "app" ) ;
89
89
let isTnsModule = appIndex >= 0 && pathParts . length > appIndex + 1 && pathParts [ appIndex + 1 ] === "tns_modules" ;
90
90
//let isTnsModule: boolean = (pathParts.length >= 3 && pathParts[0] == '' && pathParts[1] == 'app' && pathParts[2] == 'tns_modules');
91
91
if ( isTnsModule ) {
92
- // the file is part of a module, so we search it in '{ns-app}/node_modules/tns-core-modules/' and '{ns-app}/node_modules/ '
92
+ // the file is part of a module, so we search it in '{ns-app}/node_modules/'
93
93
let nsNodeModulesPath : string = path . join ( nsProjectPath , 'node_modules' ) ;
94
- let tnsCoreNodeModulesPath : string = path . join ( nsNodeModulesPath , 'tns-core-modules' ) ;
95
94
96
95
let modulePath : string = path . join . apply ( path , pathParts . slice ( appIndex + 2 ) ) ;
97
- guesses . push ( path . join ( tnsCoreNodeModulesPath , modulePath ) ) ;
98
- guesses . push ( path . join ( nsNodeModulesPath , modulePath ) ) ;
96
+ guess = path . join ( nsNodeModulesPath , modulePath ) ;
99
97
}
100
98
else {
101
- guesses . push ( path . join ( nsProjectPath , resorcePath ) ) ;
99
+ guess = path . join ( nsProjectPath , resorcePath ) ;
102
100
}
103
101
104
- for ( var guessPath of guesses ) {
105
- if ( existsSync ( guessPath ) ) {
106
- return canonicalizeUrl ( guessPath ) ;
107
- }
102
+ if ( existsSync ( guess ) ) {
103
+ return canonicalizeUrl ( guess ) ;
104
+ }
108
105
109
- let extension : string = path . extname ( guessPath ) ;
110
- let platformSpecificPath : string = guessPath . substr ( 0 , guessPath . length - extension . length ) + '.' + additionalFileExtension + extension ;
111
- if ( existsSync ( platformSpecificPath ) ) {
112
- return canonicalizeUrl ( platformSpecificPath ) ;
113
- }
106
+ let extension : string = path . extname ( guess ) ;
107
+ let platformSpecificPath : string = guess . substr ( 0 , guess . length - extension . length ) + '.' + additionalFileExtension + extension ;
108
+ if ( existsSync ( platformSpecificPath ) ) {
109
+ return canonicalizeUrl ( platformSpecificPath ) ;
114
110
}
115
111
116
112
return null ;
0 commit comments