From cf2214bba0a10e9768d6417cb9791baaac2f1a62 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 5 Sep 2014 16:15:12 -0700 Subject: [PATCH] Change getCurrentDirectory and getDefaultLibname from passing around function to its final value --- src/compiler/core.ts | 13 ++++++------- src/compiler/emitter.ts | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 432ae6ab8cd..4f50f311348 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -383,12 +383,11 @@ module ts { return [path.substr(0, rootLength)].concat(normalizedParts); } - export function getNormalizedPathComponents(path: string, getCurrentDirectory: () => string) { + export function getNormalizedPathComponents(path: string, currentDirectory: string) { var path = normalizeSlashes(path); var rootLength = getRootLength(path); if (rootLength == 0) { // If the path is not rooted it is relative to current directory - var currentDirectory = getCurrentDirectory(); path = combinePaths(normalizeSlashes(currentDirectory), path); rootLength = getRootLength(path); } @@ -444,18 +443,18 @@ module ts { } } - function getNormalizedPathOrUrlComponents(pathOrUrl: string, getCurrentDirectory: () => string) { + function getNormalizedPathOrUrlComponents(pathOrUrl: string, currentDirectory: string) { if (isUrl(pathOrUrl)) { return getNormalizedPathComponentsOfUrl(pathOrUrl); } else { - return getNormalizedPathComponents(pathOrUrl, getCurrentDirectory); + return getNormalizedPathComponents(pathOrUrl, currentDirectory); } } - export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, getCurrentDirectory: () => string, isAbsolutePathAnUrl: boolean) { - var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, getCurrentDirectory); - var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, getCurrentDirectory); + export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, isAbsolutePathAnUrl: boolean) { + var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); + var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") { // If the directory path given was of type test/cases/ then we really need components of directory to be only till its name // that is ["test", "cases", ""] needs to be actually ["test", "cases"] diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index f0883f9b6b0..6a7efc5dbcc 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -523,7 +523,7 @@ module ts { sourceMapData.sourceMapSources.push(getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.filename, - compilerHost.getCurrentDirectory, + compilerHost.getCurrentDirectory(), /*isAbsolutePathAnUrl*/ true)); sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; @@ -640,7 +640,7 @@ module ts { sourceMapData.jsSourceMappingURL = getRelativePathToDirectoryOrUrl( getDirectoryPath(normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap - compilerHost.getCurrentDirectory, + compilerHost.getCurrentDirectory(), /*isAbsolutePathAnUrl*/ true); } else { @@ -3089,7 +3089,7 @@ module ts { declFileName = getRelativePathToDirectoryOrUrl( getDirectoryPath(normalizeSlashes(jsFilePath)), declFileName, - compilerHost.getCurrentDirectory, + compilerHost.getCurrentDirectory(), /*isAbsolutePathAnUrl*/ false); referencePathsOutput += "/// " + newLine;