Skip to main content

Filesystem

API for filesystem-related functions.

Functions

Filesystem.toAbsolutePath

Converts a relative path to an absolute path.

Filesystem.toAbsolutePath(path: string, base?: string): string

Parameters

NameTypeDefault ValueDescription
pathstringRequiredThe path to convert.
basestring?nilThe base path to use.

Returns

NameTypeDescription
absolutePathstringThe absolute path.

Filesystem.readFile

Reads a file.

Filesystem.readFile(relativePath: string): buffer

Parameters

NameTypeDefault ValueDescription
relativePathstringRequiredThe relative path to the file.

Returns

NameTypeDescription
contentsbufferThe contents of the file.

Filesystem.fileExists

Checks if a file exists.

Filesystem.fileExists(path: string): boolean

Parameters

NameTypeDefault ValueDescription
pathstringRequiredThe path to the file relative to the script directory.

Returns

NameTypeDescription
existsbooleanTrue if the file exists, false otherwise.