https://github.com/fabioricali/readdirsync2
readdirSync with some useful options: recursively, exclude name and ext, get only file or directory.
https://github.com/fabioricali/readdirsync2
javascript node-js readdir readdirsync recursive
Last synced: about 1 year ago
JSON representation
readdirSync with some useful options: recursively, exclude name and ext, get only file or directory.
- Host: GitHub
- URL: https://github.com/fabioricali/readdirsync2
- Owner: fabioricali
- License: mit
- Created: 2017-09-14T09:52:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-14T10:04:57.000Z (over 8 years ago)
- Last Synced: 2024-04-24T14:38:07.657Z (almost 2 years ago)
- Topics: javascript, node-js, readdir, readdirsync, recursive
- Language: JavaScript
- Size: 36.1 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
readdirsync2
readdirSync with some useful options: recursively, exclude name and ext, get only file or directory.
## Installation
```
npm install readdirsync2 --save
```
# Example
#### Basic usage
```javascript
const readdirSync = require('readdirsync2');
readdirSync('./foo/bar');
```
#### Get only files
```javascript
readdirSync('./foo/bar', {only: 'file'});
```
#### Get only directories
```javascript
readdirSync('./foo/bar', {only: 'directory'});
```
#### Disable recursive mode
```javascript
readdirSync('./foo/bar', {recursive: false});
```
#### Ignore files with extension
```javascript
readdirSync('./foo/bar', {ignoreExt: ['.js', '.txt']});
```
#### Ignore files or directories with name
```javascript
readdirSync('./foo/bar', {ignoreName: ['index.js', 'my-folder']});
```
## readdirSync(dir, [opts]) ⇒ Array
Read directory content
**Kind**: global function
ParamTypeDefaultDescription
dirstring
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: file or directory
[opts.recursive]booleantrue
lookup also in nested directories
## Changelog
You can view the changelog here
## License
readdirsync2 is open-sourced software licensed under the MIT license
## Authors
Fabio Ricali