RoadmapShopEvents
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

MethodModifiersDescription
convertToBackslashes(inputPath)staticReplaces POSIX-style slashes with Windows-style backslashes
convertToSlashes(inputPath)staticReplaces Windows-style backslashes with POSIX-style slashes.
formatConcisely(options)staticFormats a path to look nice for reporting purposes.
formatFileLocation(options)staticFormats a file location to look nice for reporting purposes.
isDownwardRelative(inputPath)staticReturns true if the specified path is a relative path and does not use .. to walk upwards.
isEqual(path1, path2)staticReturns true if path1 and path2 refer to the same underlying path.
isUnder(childPath, parentFolderPath)staticReturns 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)staticReturns 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.