Rename function and use directorySeparator
variables
This commit is contained in:
parent
48c67cbdb5
commit
0f51bdbb4f
2 changed files with 6 additions and 5 deletions
|
@ -1018,7 +1018,8 @@ namespace ts {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export let directorySeparator = "/";
|
export const directorySeparator = "/";
|
||||||
|
const directorySeparatorCharCode = CharacterCodes.slash;
|
||||||
function getNormalizedParts(normalizedSlashedPath: string, rootLength: number) {
|
function getNormalizedParts(normalizedSlashedPath: string, rootLength: number) {
|
||||||
const parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator);
|
const parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator);
|
||||||
const normalized: string[] = [];
|
const normalized: string[] = [];
|
||||||
|
@ -1047,7 +1048,7 @@ namespace ts {
|
||||||
const normalized = getNormalizedParts(path, rootLength);
|
const normalized = getNormalizedParts(path, rootLength);
|
||||||
if (normalized.length) {
|
if (normalized.length) {
|
||||||
const joinedParts = root + normalized.join(directorySeparator);
|
const joinedParts = root + normalized.join(directorySeparator);
|
||||||
return isPathToDirectory(path) ? joinedParts + "/" : joinedParts;
|
return pathEndsWithDirectorySeparator(path) ? joinedParts + directorySeparator : joinedParts;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return root;
|
return root;
|
||||||
|
@ -1055,8 +1056,8 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A path ending with '/' refers to a directory only, never a file. */
|
/** A path ending with '/' refers to a directory only, never a file. */
|
||||||
export function isPathToDirectory(path: string): boolean {
|
export function pathEndsWithDirectorySeparator(path: string): boolean {
|
||||||
return path.charCodeAt(path.length - 1) === CharacterCodes.slash;
|
return path.charCodeAt(path.length - 1) === directorySeparatorCharCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDirectoryPath(path: Path): Path;
|
export function getDirectoryPath(path: Path): Path;
|
||||||
|
|
|
@ -670,7 +670,7 @@ namespace ts {
|
||||||
trace(state.host, Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate);
|
trace(state.host, Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolvedFileName = !isPathToDirectory(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state);
|
const resolvedFileName = !pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state);
|
||||||
|
|
||||||
return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state);
|
return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue