Skip to content

smelt.path

Tier: Host — Available in every runtime, including headless mode.

Pure path arithmetic: normalize, join, relative, expand, display, etc.

smelt.path.basename

fun(p: string): string?

Return the final component (file name) of p, or nil if p ends in ...

smelt.path.canonical

fun(p: string): string?, string?

Resolve p to its canonical absolute form (following symlinks). Returns (path, nil) on success or (nil, err_string) on failure.

smelt.path.commands_dir

fun(): string

Return the absolute path to the slash-commands directory under the user config root.

smelt.path.config_dir

fun(): string

Return the absolute path to smelt's user config directory.

smelt.path.display

fun(p: string): string

Return a user-friendly rendering of p for UI display (e.g. with the home dir abbreviated to ~).

smelt.path.expand

fun(p: string): string

Expand a leading ~ in p to the user's home directory.

smelt.path.extension

fun(p: string): string?

Return the file extension of p (without the leading dot), or nil if there is none.

smelt.path.is_absolute

fun(p: string): boolean

Return true if p is an absolute path on the current platform.

smelt.path.join

fun(...: string): string

Join the variadic parts into a single path using the platform separator.

smelt.path.normalize

fun(p: string): string

Normalize p by collapsing redundant ., .., and separator components without touching the filesystem.

smelt.path.parent

fun(p: string): string?

Return the parent directory of p, or nil if p has no parent component.

smelt.path.relative

fun(base: string, target: string): string

Return the path of target expressed relative to base.