Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

readdirsync2

fabioricali28MIT1.0.2

readdirSync with some useful options: recursively, exclude name and ext, get only file or directory.

readdir, recursive, filter, ext, directory, file

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

const readdirSync = require('readdirsync2');
readdirSync('./foo/bar');

Get only files

readdirSync('./foo/bar', {only: 'file'});

Get only directories

readdirSync('./foo/bar', {only: 'directory'});

Disable recursive mode

readdirSync('./foo/bar', {recursive: false});

Ignore files with extension

readdirSync('./foo/bar', {ignoreExt: ['.js', '.txt']});

Ignore files or directories with name

readdirSync('./foo/bar', {ignoreName: ['index.js', 'my-folder']});

API

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

changelog

Change Log

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

[1.0.2] - 2017-09-14

  • Added test

[1.0.1] - 2017-09-14

  • First release