Skip to content

Commit cf2214b

Browse files
author
Yui T
committed
Change getCurrentDirectory and getDefaultLibname from passing around
function to its final value
1 parent 271bb29 commit cf2214b

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/compiler/core.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,11 @@ module ts {
383383
return [path.substr(0, rootLength)].concat(normalizedParts);
384384
}
385385

386-
export function getNormalizedPathComponents(path: string, getCurrentDirectory: () => string) {
386+
export function getNormalizedPathComponents(path: string, currentDirectory: string) {
387387
var path = normalizeSlashes(path);
388388
var rootLength = getRootLength(path);
389389
if (rootLength == 0) {
390390
// If the path is not rooted it is relative to current directory
391-
var currentDirectory = getCurrentDirectory();
392391
path = combinePaths(normalizeSlashes(currentDirectory), path);
393392
rootLength = getRootLength(path);
394393
}
@@ -444,18 +443,18 @@ module ts {
444443
}
445444
}
446445

447-
function getNormalizedPathOrUrlComponents(pathOrUrl: string, getCurrentDirectory: () => string) {
446+
function getNormalizedPathOrUrlComponents(pathOrUrl: string, currentDirectory: string) {
448447
if (isUrl(pathOrUrl)) {
449448
return getNormalizedPathComponentsOfUrl(pathOrUrl);
450449
}
451450
else {
452-
return getNormalizedPathComponents(pathOrUrl, getCurrentDirectory);
451+
return getNormalizedPathComponents(pathOrUrl, currentDirectory);
453452
}
454453
}
455454

456-
export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, getCurrentDirectory: () => string, isAbsolutePathAnUrl: boolean) {
457-
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, getCurrentDirectory);
458-
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, getCurrentDirectory);
455+
export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, isAbsolutePathAnUrl: boolean) {
456+
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
457+
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
459458
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
460459
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name
461460
// that is ["test", "cases", ""] needs to be actually ["test", "cases"]

src/compiler/emitter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ module ts {
523523

524524
sourceMapData.sourceMapSources.push(getRelativePathToDirectoryOrUrl(sourcesDirectoryPath,
525525
node.filename,
526-
compilerHost.getCurrentDirectory,
526+
compilerHost.getCurrentDirectory(),
527527
/*isAbsolutePathAnUrl*/ true));
528528
sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1;
529529

@@ -640,7 +640,7 @@ module ts {
640640
sourceMapData.jsSourceMappingURL = getRelativePathToDirectoryOrUrl(
641641
getDirectoryPath(normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath
642642
combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap
643-
compilerHost.getCurrentDirectory,
643+
compilerHost.getCurrentDirectory(),
644644
/*isAbsolutePathAnUrl*/ true);
645645
}
646646
else {
@@ -3089,7 +3089,7 @@ module ts {
30893089
declFileName = getRelativePathToDirectoryOrUrl(
30903090
getDirectoryPath(normalizeSlashes(jsFilePath)),
30913091
declFileName,
3092-
compilerHost.getCurrentDirectory,
3092+
compilerHost.getCurrentDirectory(),
30933093
/*isAbsolutePathAnUrl*/ false);
30943094

30953095
referencePathsOutput += "/// <reference path=\"" + declFileName + "\" />" + newLine;

0 commit comments

Comments
 (0)