A promise that resolves with an array of string representing the
entries result excluding '.'
and '..'
or an empty array ([]
)
if any files and directories does not match with the specified filter options.
Error - If there is an error occurred while reading a directory.
URIError - If the given URL path contains invalid file URL scheme or using unsupported protocols.
// List all JavaScript files in current directory recursively,
// but excluding files from 'tests' directory
lsFiles('.', {
recursive: true,
match: /.+\.[cm]*js$/,
exclude: /[\/\\]\btests\b[\/\\]/
}).then((files) => console.log(files));
0.1.0
Generated using TypeDoc v0.25.12
Lists files in the specified directory path, filtering by a regular expression pattern.
The returned entries are configurable using the additional options, such as listing recursively to subdirectories, and filter specific file and/or directory names using a regular expression.
The additional
options
can be an object or a regex pattern to specify only the match field. If passed as aRegExp
object, the rest options (except thematch
field) for reading the directory will uses default options.If the
options
argument not specified (orundefined
), then it uses the default value:History
1.0.0
As of version 1.0.0, this function now accepts file URL paths. This can be either a string URL path or a
URL
object, and it must follow the'file:'
protocol. AnURIError
will be thrown if the specified file URL path has invalid file URL syntax or is used with unsupported protocols.0.1.0
Added in version 0.1.0.