Interface WalkOptions

Options provided to all walk methods.

interface WalkOptions {
    filter?: ((entry: PathBase) => boolean);
    follow?: boolean;
    walkFilter?: ((entry: PathBase) => boolean);
    withFileTypes?: boolean;
}

Properties

filter?: ((entry: PathBase) => boolean)

Only return entries where the provided function returns true.

This will not prevent directories from being traversed, even if they do not pass the filter, though it will prevent directories themselves from being included in the result set. See walkFilter

Asynchronous functions are not supported here.

By default, if no filter is provided, all entries and traversed directories are included.

follow?: boolean

Attempt to read directory entries from symbolic links. Otherwise, only actual directories are traversed. Regardless of this setting, a given target path will only ever be walked once, meaning that a symbolic link to a previously traversed directory will never be followed.

Setting this imposes a slight performance penalty, because readlink must be called on all symbolic links encountered, in order to avoid infinite cycles.

false
walkFilter?: ((entry: PathBase) => boolean)

Only traverse directories (and in the case of follow being set to true, symbolic links to directories) if the provided function returns true.

This will not prevent directories from being included in the result set, even if they do not pass the supplied filter function. See filter to do that.

Asynchronous functions are not supported here.

withFileTypes?: boolean

Return results as PathBase objects rather than strings. When set to false, results are fully resolved paths, as returned by PathBase.fullpath.

true