Documentation
¶
Overview ¶
Package nodepath converts path inputs the way upstream's Node runtime does on the platform orb runs on: url.fileURLToPath, url.pathToFileURL, and the win32 Git Bash/MSYS drive-path rewrite from upstream utils/paths.ts.
Index ¶
- Constants
- Variables
- func AgentDir(configured string) (string, error)
- func Expand(path string) (string, error)
- func FileURLToPath(raw string) (string, error)
- func HomeDir() (string, error)
- func Normalize(path string) string
- func NormalizeShellPath(path string) string
- func NormalizeUnicodeSpaces(value string) string
- func PathToFileURL(path string) string
- func Resolve(path, base string) string
Constants ¶
const AgentDirEnv = "ORB_AGENT_DIR"
AgentDirEnv names the variable that moves Orb's agent directory.
Variables ¶
var ( ErrInvalidURL = errors.New("Invalid URL") //nolint:staticcheck // Node's error text. ErrURIMalformed = errors.New("URI malformed") )
Node's error messages for rejected file URLs (ERR_INVALID_URL, URIError, ERR_INVALID_FILE_URL_PATH); their text is observable, capitals included.
Functions ¶
func AgentDir ¶ added in v0.19.1
AgentDir is Orb's agent directory: configured, the value of AgentDirEnv, when it is set, else ~/.orb/agent.
func Expand ¶ added in v0.19.1
Expand resolves a leading ~ against the user's home, when there is one, and converts a file:// URL to its path.
func FileURLToPath ¶
FileURLToPath parses raw with the WHATWG rules for the file scheme and converts it like Node's url.fileURLToPath: POSIX rejects hosts, win32 maps them to UNC paths and requires a drive letter otherwise.
func HomeDir ¶ added in v0.19.1
HomeDir is the user's home directory, from the account database when $HOME is unset.
func Normalize ¶ added in v0.19.1
Normalize is upstream's normalizePath: the shell-drive rewrite, then Expand; a malformed file URL stays an ordinary path.
func NormalizeShellPath ¶
NormalizeShellPath rewrites Git Bash, MSYS, Cygwin and WSL drive paths ("/c/x", "/mnt/c/x", "/cygdrive/c/x") to native drive paths on win32 and returns path unchanged elsewhere.
func NormalizeUnicodeSpaces ¶ added in v0.14.0
NormalizeUnicodeSpaces folds pasted path spacing without changing other whitespace.
func PathToFileURL ¶
PathToFileURL encodes an absolute native path like Node's url.pathToFileURL.
Types ¶
This section is empty.