import { PathRef } from "https://deno.land/x/dax@0.31.1/src/path.ts";
Holds a reference to a path providing helper methods.
Create one via $
: const srcDir = $.path("src");
Constructors
Methods
Gets the file or directory name of the path.
Changes the permissions of the file or directory.
Synchronously changes the permissions of the file or directory.
Changes the ownership permissions of the file.
Synchronously changes the ownership permissions of the file.
Copies the file returning a promise that resolves to the destination path.
Copies the file returning a promise that resolves to the destination path synchronously.
Creates a new file or opens the existing one.
Creates a file throwing if a file previously existed.
Synchronously creates a file throwing if a file previously existed.
Creates a symlink to the provided target path.
Creates a symlink at the provided path with the provided target text.
Synchronously creates a symlink to the provided target path.
Synchronously creates a symlink at the provided path with the provided target text.
Synchronously creates a new file or opens the existing one.
Gets the directory path. In most cases, it is recommended
to use .parent()
instead since it will give you a PathRef
.
Ensures that a directory is empty. Deletes directory contents if the directory is not empty. If the directory does not exist, it is created. The directory itself is not deleted.
Synchronous version of emptyDir()
Gets if the path exists. Beaware of TOCTOU issues.
Synchronously gets if the path exists. Beaware of TOCTOU issues.
Expands the glob using the current path as the root.
Synchronously expands the glob using the current path as the root.
Returns the extension of the path with leading period or undefined if there is no extension.
Gets if this path is an absolute path.
Follows symlinks and gets if this path is a directory.
Follows symlinks and gets if this path is a file.
Gets if this path is relative.
Gets if this path is a symlink.
Resolves the Deno.FileInfo
of this path without
following symlinks.
Synchronously resolves the Deno.FileInfo
of this path
without following symlinks.
Creates a directory at this path.
Synchronously creates a directory at this path.
Normalizes the path
, resolving '..'
and '.'
segments.
Note that resolving these segments does not necessarily mean that all will be eliminated.
A '..'
at the top-level will be preserved, and an empty path is canonically '.'
.
Opens a file.
Opens a file synchronously.
Gets the parent directory or returns undefined if the parent is the root directory.
Gets the parent or throws if the current directory was the root.
Opens the file and pipes it to the writable stream.
Reads the bytes from the file.
Synchronously reads the bytes from the file.
Reads only the directory file paths, not including symlinks.
Synchronously reads only the directory file paths, not including symlinks.
Synchronously reads the entries in the directory.
Reads and parses the file as JSON, throwing if it doesn't exist or is not valid JSON.
Synchronously reads and parses the file as JSON, throwing if it doesn't exist or is not valid JSON.
Calls .readBytes()
, but returns undefined if the path doesn't exist.
Calls .readBytesSync()
, but returns undefined if the path doesn't exist.
Calls .readJson()
, but returns undefined if the file doesn't exist.
Calls .readJsonSync()
, but returns undefined if the file doesn't exist.
Calls .readText()
, but returns undefined when the path doesn't exist.
Calls .readTextSync()
, but returns undefined when the path doesn't exist.
Reads the text from the file.
Synchronously reads the text from the file.
Synchronously resolves to the absolute normalized path, with symbolic links resolved.
Gets the relative path from this path to the specified path.
Removes the file or directory from the file system.
Removes the file or directory from the file system synchronously.
Renames the file or directory returning a promise that resolves to the renamed path.
Renames the file or directory returning a promise that resolves to the renamed path synchronously.
Resolves this path to an absolute path along with the provided path segments.
Resolves the Deno.FileInfo
of this path following symlinks.
Synchronously resolves the Deno.FileInfo
of this
path following symlinks.
Gets the string representation of this path.
Walks the file tree rooted at the current path, yielding each file or directory in the tree filtered according to the given options.
Synchronously walks the file tree rooted at the current path, yielding each file or directory in the tree filtered according to the given options.
Gets a new path reference with the provided file or directory name.
Gets a new path reference with the provided extension.
Writes out the provided bytes to the file.
Writes out the provided object as compact JSON.
Writes out the provided object as formatted JSON.
Synchronously writes out the provided object as formatted JSON.
Synchronously writes out the provided object as compact JSON.
Synchronously writes out the provided bytes to the file.
Writes out the provided text to the file.
Synchronously writes out the provided text to the file.