Rush StackShopBlogEvents
Skip to main content

Home > @rushstack/node-core-library > Path

Path class

Common operations for manipulating file and directory paths.

Signature:

export declare class Path 

Remarks

This API is intended to eventually be a complete replacement for the NodeJS "path" API.

Methods

Method

Modifiers

Description

convertToBackslashes(inputPath)

static

Replaces POSIX-style slashes with Windows-style backslashes

convertToPlatformDefault(inputPath)

static

Replaces slashes or backslashes with the appropriate slash for the current operating system.

convertToSlashes(inputPath)

static

Replaces Windows-style backslashes with POSIX-style slashes.

formatConcisely(options)

static

Formats a path to look nice for reporting purposes.

formatFileLocation(options)

static

Formats a file location to look nice for reporting purposes.

isDownwardRelative(inputPath)

static

Returns true if the specified path is a relative path and does not use .. to walk upwards.

isEqual(path1, path2)

static

Returns true if path1 and path2 refer to the same underlying path.

isUnder(childPath, parentFolderPath)

static

Returns true if "childPath" is located inside the "parentFolderPath" folder or one of its child folders. Note that "parentFolderPath" is not considered to be under itself. The "childPath" can refer to any type of file system object.

isUnderOrEqual(childPath, parentFolderPath)

static

Returns true if "childPath" is equal to "parentFolderPath", or if it is inside that folder or one of its children. The "childPath" can refer to any type of file system object.