Interface: Tree

Virtual file system tree.

Table of contents

Properties

Methods

Properties

root

root: string

Root of the workspace. All paths are relative to this.

Methods

changePermissions

changePermissions(filePath, mode): void

Changes permissions of a file.

Parameters

NameTypeDescription
filePathstringA path to a file.
modeModeThe permission to be granted on the file, given as a string (e.g 755) or octal integer (e.g 0o755). See https://nodejs.org/api/fs.html#fs_file_modes.

Returns

void


children

children(dirPath): string[]

Returns the list of children of a folder.

Parameters

NameType
dirPathstring

Returns

string[]


delete

delete(filePath): void

Delete the file.

Parameters

NameType
filePathstring

Returns

void


exists

exists(filePath): boolean

Check if a file exists.

Parameters

NameType
filePathstring

Returns

boolean


isFile

isFile(filePath): boolean

Check if this is a file or not.

Parameters

NameType
filePathstring

Returns

boolean


listChanges

listChanges(): FileChange[]

Returns the list of currently recorded changes.

Returns

FileChange[]


read

read(filePath): Buffer

Read the contents of a file.

Parameters

NameTypeDescription
filePathstringA path to a file.

Returns

Buffer

read(filePath, encoding): string

Read the contents of a file as string.

Parameters

NameTypeDescription
filePathstringA path to a file.
encodingBufferEncodingthe encoding for the result

Returns

string


rename

rename(from, to): void

Rename the file or the folder.

Parameters

NameType
fromstring
tostring

Returns

void


write

write(filePath, content, options?): void

Update the contents of a file or create a new file.

Parameters

NameType
filePathstring
contentstring | Buffer
options?TreeWriteOptions

Returns

void