Skip to content

Commit 0435c14

Browse files
author
Yui T
committed
Add getEmitOutput and update call to getCurrentDirectory
1 parent 9bbbdec commit 0435c14

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/compiler/core.ts

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

386-
export function getNormalizedPathComponents(path: string, currentDirectory: string) {
386+
export function getNormalizedPathComponents(path: string, getCurrentDirectory: ()=>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();
391392
path = combinePaths(normalizeSlashes(currentDirectory), path);
392393
rootLength = getRootLength(path);
393394
}
@@ -443,18 +444,18 @@ module ts {
443444
}
444445
}
445446

446-
function getNormalizedPathOrUrlComponents(pathOrUrl: string, currentDirectory: string) {
447+
function getNormalizedPathOrUrlComponents(pathOrUrl: string, getCurrentDirectory: ()=>string) {
447448
if (isUrl(pathOrUrl)) {
448449
return getNormalizedPathComponentsOfUrl(pathOrUrl);
449450
}
450451
else {
451-
return getNormalizedPathComponents(pathOrUrl, currentDirectory);
452+
return getNormalizedPathComponents(pathOrUrl, getCurrentDirectory);
452453
}
453454
}
454455

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);
458459
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
459460
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name
460461
// 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)