Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/yxz/path/path.ts>Path

Deno Standard Extensions
Latest
class Path
import { Path } from "https://deno.land/x/yxz@0.32.0/path/path.ts";

A class to represent filesystem path.

Constructors

new
private
Path(filepath: string)

Properties

private
readonly
[filepathSymbol]: string
readonly
ext

Return the extension of path.

readonly
name

Return the name of path.

readonly
parent
readonly
parents: Array<Path>
readonly
stem

Return the name of the path, without extension.

readonly
[Symbol.toStringTag]

Methods

chmod(mode: number)
chmodSync(mode: number)
chown(uid: number | null, gid: number | null)
chownSync(uid: number | null, gid: number | null)
copyFile(toPath: Path | string | URL)
copyFileSync(toPath: Path | string | URL)
ensureSymlinkSync(dest: Path | string)
equals(otherPath:
| Path
| string
| undefined
| null
)

Return a new path with expanded ~ and ~user constructs.

If a home directory can’t be resolved, an error is raised.

glob(glob: string, opts?: GlobOptions): AsyncIterableIterator<Path>
globSync(glob: string, opts?: GlobOptions): IterableIterator<Path>
isDir(): Promise<boolean>
isFile(): Promise<boolean>
joinpath(...other: string[])
linkSync(newpath: Path | string)
move(dest: Path | string, options?: { overwrite?: boolean; })
moveSync(dest: Path | string, options?: { overwrite?: boolean; })
relative(otherPath: Path)
rename(newpath: Path | string | URL): Promise<Path>
renameSync(newpath: Path | string | URL): Path
symlinkSync(newpath: Path | string | URL, options?: Deno.SymlinkOptions)
truncate(len?: number)
truncateSync(len?: number)
walk(options?: WalkOptions)
watch(options?: { recursive: boolean; })
writeFile(data: Uint8Array, options?: Deno.WriteFileOptions)
writeFileSync(data: Uint8Array, options?: Deno.WriteFileOptions)
writeJsonFile(value: JsonValue, options?: Deno.WriteFileOptions & { replacer?: (number | string)[] | null; space?: string | number; })
writeTextFile(data: string, options?: Deno.WriteFileOptions)
writeTextFileSync(data: string, options?: Deno.WriteFileOptions)
[Symbol.toPrimitive](hint: string)

Static Properties

_cache: Cache
readonly
delimiter
readonly
sep

Static Methods

cache(...pathSegments: string[])
config(...pathSegments: string[])
cwd(...pathSegments: string[])

Returns path representing the current directory.

exe(name: string): Promise<Path | undefined>

Searches for an executable named file in the directories named by the PATH environment variable.

from(...pathSegments: string[])
fromFileUrl(url: string | URL)
fromImportMeta(importMeta: ImportMeta, url?)

Returns path relative to import.meta.

Note: As hosted script don't resolve to file system path, library should avoid this method.

home(...pathSegments: string[])

Returns path representing the user’s home directory.

If the home directory can’t be resolved, throw error.

Converts the PATH environment variable into an array of Path instances.