@@ -83,34 +83,30 @@ export function retryAsync(fn: () => Promise<any>, timeoutMs: number): Promise<a
8383}
8484
8585function tryFindSourcePathInNSProject ( nsProjectPath : string , additionalFileExtension : string , resorcePath : string ) : string {
86- let guesses = [ ] ;
86+ let guess : string = "" ;
8787 const pathParts = resorcePath . split ( path . sep ) ;
8888 let appIndex = pathParts . indexOf ( "app" ) ;
8989 let isTnsModule = appIndex >= 0 && pathParts . length > appIndex + 1 && pathParts [ appIndex + 1 ] === "tns_modules" ;
9090 //let isTnsModule: boolean = (pathParts.length >= 3 && pathParts[0] == '' && pathParts[1] == 'app' && pathParts[2] == 'tns_modules');
9191 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/'
9393 let nsNodeModulesPath : string = path . join ( nsProjectPath , 'node_modules' ) ;
94- let tnsCoreNodeModulesPath : string = path . join ( nsNodeModulesPath , 'tns-core-modules' ) ;
9594
9695 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 ) ;
9997 }
10098 else {
101- guesses . push ( path . join ( nsProjectPath , resorcePath ) ) ;
99+ guess = path . join ( nsProjectPath , resorcePath ) ;
102100 }
103101
104- for ( var guessPath of guesses ) {
105- if ( existsSync ( guessPath ) ) {
106- return canonicalizeUrl ( guessPath ) ;
107- }
102+ if ( existsSync ( guess ) ) {
103+ return canonicalizeUrl ( guess ) ;
104+ }
108105
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 ) ;
114110 }
115111
116112 return null ;
0 commit comments