Skip to main content

Class: WriteContainment

assertWritableWithin and prepareFixedNameWrite for many writes into one root: the real path of the root is computed once, and every directory is checked once.

Constructors​

Constructor​

new WriteContainment(root, what?): WriteContainment

Parameters​

root​

string

what?​

string = "file"

what is written, for the error message, e.g. "extraResources file"

Returns​

WriteContainment

Properties​

root​

readonly root: string


what​

readonly what: string = "file"

what is written, for the error message, e.g. "extraResources file"

Methods​

assertDirectoryWithin()​

assertDirectoryWithin(dir, dest?): Promise<void>

Parameters​

dir​

string

dest?​

string = dir

Returns​

Promise<void>


ensureDir()​

ensureDir(dir): Promise<void>

Checks dir, creates it (and its parents) and checks it again, now that it exists. Done once per directory.

Parameters​

dir​

string

Returns​

Promise<void>


getRealRoot()​

getRealRoot(): Promise<string>

Returns​

Promise<string>


prepareFile()​

prepareFile(dest): Promise<void>

Makes dest ready to be written as a regular file: its directory is created and checked (see ensureDir), and what is at dest that is neither a regular file nor a directory, such as a symlink, is removed, so that the write does not follow it.

Parameters​

dest​

string

Returns​

Promise<void>