@@ -383,11 +383,12 @@ module ts {
383
383
return [ path . substr ( 0 , rootLength ) ] . concat ( normalizedParts ) ;
384
384
}
385
385
386
- export function getNormalizedPathComponents ( path : string , currentDirectory : string ) {
386
+ export function getNormalizedPathComponents ( path : string , getCurrentDirectory : ( ) => string ) {
387
387
var path = normalizeSlashes ( path ) ;
388
388
var rootLength = getRootLength ( path ) ;
389
389
if ( rootLength == 0 ) {
390
390
// If the path is not rooted it is relative to current directory
391
+ var currentDirectory = getCurrentDirectory ( ) ;
391
392
path = combinePaths ( normalizeSlashes ( currentDirectory ) , path ) ;
392
393
rootLength = getRootLength ( path ) ;
393
394
}
@@ -443,18 +444,18 @@ module ts {
443
444
}
444
445
}
445
446
446
- function getNormalizedPathOrUrlComponents ( pathOrUrl : string , currentDirectory : string ) {
447
+ function getNormalizedPathOrUrlComponents ( pathOrUrl : string , getCurrentDirectory : ( ) => string ) {
447
448
if ( isUrl ( pathOrUrl ) ) {
448
449
return getNormalizedPathComponentsOfUrl ( pathOrUrl ) ;
449
450
}
450
451
else {
451
- return getNormalizedPathComponents ( pathOrUrl , currentDirectory ) ;
452
+ return getNormalizedPathComponents ( pathOrUrl , getCurrentDirectory ) ;
452
453
}
453
454
}
454
455
455
- export function getRelativePathToDirectoryOrUrl ( directoryPathOrUrl : string , relativeOrAbsolutePath : string , currentDirectory : string , isAbsolutePathAnUrl : boolean ) {
456
- var pathComponents = getNormalizedPathOrUrlComponents ( relativeOrAbsolutePath , currentDirectory ) ;
457
- var directoryComponents = getNormalizedPathOrUrlComponents ( directoryPathOrUrl , currentDirectory ) ;
456
+ export function getRelativePathToDirectoryOrUrl ( directoryPathOrUrl : string , relativeOrAbsolutePath : string , getCurrentDirectory : ( ) => string , isAbsolutePathAnUrl : boolean ) {
457
+ var pathComponents = getNormalizedPathOrUrlComponents ( relativeOrAbsolutePath , getCurrentDirectory ) ;
458
+ var directoryComponents = getNormalizedPathOrUrlComponents ( directoryPathOrUrl , getCurrentDirectory ) ;
458
459
if ( directoryComponents . length > 1 && directoryComponents [ directoryComponents . length - 1 ] === "" ) {
459
460
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name
460
461
// that is ["test", "cases", ""] needs to be actually ["test", "cases"]
0 commit comments