MCPcopy Create free account
hub / github.com/microsoft/typescript-go / GetDirectoryPath

Function GetDirectoryPath

internal/tspath/path.go:250–263  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

248}
249
250func GetDirectoryPath(path string) string {
251 path = NormalizeSlashes(path)
252
253 // If the path provided is itself a root, then return it.
254 rootLength := GetRootLength(path)
255 if rootLength == len(path) {
256 return path
257 }
258
259 // return the leading portion of the path up to the last (non-terminal) directory separator
260 // but not including any trailing directory separator.
261 path = RemoveTrailingDirectorySeparator(path)
262 return path[:max(rootLength, strings.LastIndex(path, "/"))]
263}
264
265func (p Path) GetDirectoryPath() Path {
266 return Path(GetDirectoryPath(string(p)))

Callers 15

nearestExistingAncestorFunction · 0.92
ResolveModuleNameMethod · 0.92
resolveConfigMethod · 0.92
tryAddingExtensionsMethod · 0.92
updateTsconfigFilesMethod · 0.92
updateRelativePathMethod · 0.92
getFragmentDirectoryFunction · 0.92

Calls 5

NormalizeSlashesFunction · 0.85
GetRootLengthFunction · 0.85
lenFunction · 0.85
maxFunction · 0.85

Tested by 2

baselineParseConfigWithFunction · 0.74
TestGetDirectoryPathFunction · 0.68