readfiles-sync
v0.0.5
Published
Recursively reads all files or directories in the directory.
Downloads
11
Maintainers
Readme
readfiles-sync
Installation
Install
$ npm install readfiles-sync --save
# or
$ yarn add readfiles-sync
ES6
import readfilesSync from 'readfiles-sync'
// or
import { readdirSync, readfilesSync } from 'readfiles-sync'
CommonJS
const rfs = require('readfiles-sync')
// rsf = { readfilesSync, readdirSync }
// or
const readfilesSync = require('readfiles-sync').readfilesSync
const readfilesSync = require('readfiles-sync').default
const readdirSync = require('readfiles-sync').readdirSync
Usage
const fileList = readfilesSync('./')
const fileList = readfilesSync({
dir: './',
relative: true, //default is true
exclude_dir: true, //default is true
filter: function(fp) {
return true
},
ignore: ['.DS_Store', '.git', 'node_modules']
})
const fileList2 = readdirSync({
dir: './',
relative: true, //default is true
exclude_dir: false, //default is false
filter: function(fp) {
return true
},
ignore: ['.DS_Store', '.git', 'node_modules']
})
Options
readfilesSync
| Name | Required | Type | Explain | Defalut |
| --- | --- | --- | --- | --- |
| dir | true
| String
| Dirname to scan. | no default |
| relative | false
| Boolean
| The output results use relative paths. | true
|
| exclude_dir | false
| Boolean
| Output result exclusion directory. | true
|
| filter | false
| Function
| Output only files hit by filters. | function(fp) {\n return true\n }
|
readdirSync
| Name | Required | Type | Explain | Defalut |
| --- | --- | --- | --- | --- |
| dir | true
| String
| Dirname to scan. | no default |
| relative | false
| Boolean
| The output results use relative paths. | true
|
| exclude_dir | false
| Boolean
| Output result exclusion directory. | false
|
| filter | false
| Function
| Output only directories hit by filters. | function(fp) {\n return true\n }
|