readdirsync2
readdirSync with some useful options: recursively, exclude name and ext, get only file or directory.Installation
npm install readdirsync2 --save
Example
Basic usage
const readdirSync = ;;
Get only files
;
Get only directories
;
Disable recursive mode
;
Ignore files with extension
;
Ignore files or directories with name
;
API
Array
readdirSync(dir, [opts]) ⇒ Read directory content
Kind: global function
Param | Type | Default | Description |
---|---|---|---|
dir | string | directory path |
|
[opts] | Object | options |
|
[opts.ignoreExt] | Array | [] | an array of extensions to ignore, eg: '.txt' |
[opts.ignoreName] | Array | [] | an array of filename or directory to ignore, eg: 'index.js' |
[opts.only] | string | get file or directory or both. The value can be: |
|
[opts.recursive] | boolean | true | lookup also in nested directories |
Changelog
You can view the changelog here
License
readdirsync2 is open-sourced software licensed under the MIT license