paths
Functions
basename()
Returns the last path segment, optionally removing a known extension suffix.
Parameters
path
string
Path to inspect.
extension?
string
Optional extension suffix to remove from the result.
Returns
string
The basename of path.
Example
See
Powered by pathe (MIT License): https://github.com/unjs/pathe
dirname()
Returns the parent directory portion of a path.
Parameters
path
string
Path to inspect.
Returns
string
The directory name portion of path.
Example
See
Powered by pathe (MIT License): https://github.com/unjs/pathe
extname()
Returns the file extension of a path, including the leading dot.
Parameters
path
string
Path to inspect.
Returns
string
The extension portion of path, or an empty string when none exists.
Example
See
Powered by pathe (MIT License): https://github.com/unjs/pathe
filename()
Returns the filename without its extension.
This is useful for deriving stable artifact names without manually stripping directory segments or extensions.
Parameters
path
string
Path to inspect.
Returns
string | undefined
The filename without its extension, or undefined when it cannot be derived.
Example
See
Powered by pathe (MIT License): https://github.com/unjs/pathe
isAbsolute()
Checks whether a path is absolute.
Parameters
path
string
Path to inspect.
Returns
boolean
true when path is absolute, otherwise false.
Example
See
Powered by pathe (MIT License): https://github.com/unjs/pathe
join()
Joins path segments using deterministic forward-slash normalization.
This is a thin wrapper around pathe.join, which keeps behavior consistent
across platforms and normalizes path separators to /.
Parameters
parts
...string[]
Path segments to join.
Returns
string
The normalized joined path.
Example
See
Powered by pathe (MIT License): https://github.com/unjs/pathe
normalize()
Normalizes a path by collapsing redundant separators and dot segments.
This is helpful when plugin code receives mixed Windows and POSIX-style path input and needs a single predictable format.
Parameters
path
string
Path to normalize.
Returns
string
The normalized path using / separators.
Example
See
Powered by pathe (MIT License): https://github.com/unjs/pathe
relative()
Computes the relative path from one location to another.
Parameters
from
string
Starting path.
to
string
Destination path.
Returns
string
The normalized relative path from from to to.
Example
See
Powered by pathe (MIT License): https://github.com/unjs/pathe
resolve()
Resolves one or more path segments into a normalized absolute or rooted path.
This is useful when plugin code needs stable path resolution without relying on platform-specific separators.
Parameters
parts
...string[]
Path segments to resolve.
Returns
string
The resolved normalized path.
Example
resolve("/workspace/plugin", "src", "../dist/index.js");
// returns "/workspace/plugin/dist/index.js"
See
Powered by pathe (MIT License): https://github.com/unjs/pathe