Interface ScanOptions

Interface of the options object used with "scan" function

interface ScanOptions {
    depth?: number;
    descendants?: boolean;
    descendantsIgnoreDirectories?: boolean;
    emptyDirectory?: boolean;
    exclude?: string | RegExp | (string | RegExp)[];
    excludeEmptyDirectories?: boolean;
    extensions?: string[];
    followLinks?: boolean;
    hash?: boolean;
    hashAlgorithm?: "md5" | "sha1";
    hashEncoding?: BinaryToTextEncoding;
    homeShortcut?: boolean;
    matches?: string | RegExp | (string | RegExp)[];
    normalize?: boolean;
    postSorted?: boolean | PostSortMethodPredefined | PostSortDiscriminator;
    showHidden?: boolean;
    size?: boolean;
    sizeInBytes?: boolean;
    skipErrors?: boolean;
    sorted?: boolean | SortMethodPredefined | SortDiscriminator;
    stat?: boolean;
    symbolicLinks?: boolean;
}

Properties

depth?: number

It is a number which says the max depth the algorithm can reach scanning the given path. All files and dirs which are beyound the max depth will not be considered by the algorithm

descendants?: boolean

If true, also the number of descendants of each node will be added to the result.

descendantsIgnoreDirectories?: boolean

If true, only files will be count as descendants of a node. It does not have effect if [[descendants]] option is not true.

emptyDirectory?: boolean

If true, every node of type directory in the result will contain isEmpty property, which will be true if the folder contains no files and no directories

exclude?: string | RegExp | (string | RegExp)[]

It is a regex, string (glob patterns) or array of them and all the matching paths will not be considered by the algorithm.

excludeEmptyDirectories?: boolean

If true, every empty directory will be excluded from the result. If the directory is not empty but all the contained files and directories are excluded by other options such as exclude or extensions, the directory will not be included in the result

extensions?: string[]

It is an array of strings and all the files whose extension is not included in that array will be skipped by the algorithm. If value is undefined, all file extensions will be considered, if it is [], no files will be included

followLinks?: boolean

If true, all symbolic links will be followed, including even their content if they link to a folder. Could not work on Windows

hash?: boolean

If true, every node in the result will contain hash property, computed by taking in consideration the name and the content of the node. If the node is a folder, all his considered inner files will be used by the algorithm

hashAlgorithm?: "md5" | "sha1"

Hash algorithm used by cryptojs to return the hash

hashEncoding?: BinaryToTextEncoding

Hash encoding used by cryptojs to return the hash

homeShortcut?: boolean

If true, the unix homedir shortcut ~ will be expanded to the user home directory

matches?: string | RegExp | (string | RegExp)[]

It is a regex, string (glob pattern) or array of them and all the non-matching paths will not be considered by the algorithm. Note: All the ancestors of a matching node will be added.

normalize?: boolean

If true, on windows, normalize each path replacing each backslash \\ with a slash /

If true, the child nodes of a node will be ordered. The value can be both boolean for default alpha order, a custom sorting function or a predefined sorting method in [[PostSortMethodPredefined]].

showHidden?: boolean

If true, all hidden files and dirs will be included in the result. A hidden file or a directory has a name which starts with a dot and in some systems like Linux are hidden

size?: boolean

If true, every node in the result will contain size property. Same as sizeInBytes, but it is a string rounded to the second decimal digit and with an appropriate unit

sizeInBytes?: boolean

If true, every node in the result will contain sizeInBytes property as the number of bytes of the content. If a node is a folder, only its considered inner files will be computed to have this size

skipErrors?: boolean

If true, folders whose user has not permissions will be skipped. An error will be thrown otherwise. Note: in fact every error thrown by fs calls will be ignored

If true, directories and files will be scanned ordered by path. The value can be both boolean for default alpha order, a custom sorting function or a predefined sorting method in [[SortMethodPredefined]].

stat?: boolean

If true every node of the result will contain stat property, provided by fs.lstat or fs.stat

symbolicLinks?: boolean

If true, all symbolic links found will be included in the result. Could not work on Windows