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

Function EnsurePathIsNonModuleName

internal/tspath/path.go:924–929  ·  view source on GitHub ↗

EnsurePathIsNonModuleName ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed with `./` or `../`) so as not to be confused with an unprefixed module name.

(path string)

Source from the content-addressed store, hash-verified

922// EnsurePathIsNonModuleName ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
923// with `./` or `../`) so as not to be confused with an unprefixed module name.
924func EnsurePathIsNonModuleName(path string) string {
925 if !PathIsAbsolute(path) && !PathIsRelative(path) {
926 return "./" + path
927 }
928 return path
929}
930
931func IsExternalModuleNameRelative(moduleName string) bool {
932 // TypeScript 1.0 spec (April 2014): 11.2.1

Callers 4

relativeToBuildInfoMethod · 0.92
GetRelativePathFromFileFunction · 0.85

Calls 2

PathIsAbsoluteFunction · 0.85
PathIsRelativeFunction · 0.85

Tested by

no test coverage detected