|
4 年之前 | |
---|---|---|
.. | ||
lib | 4 年之前 | |
node_modules | 4 年之前 | |
.babelrc | 4 年之前 | |
.eslintignore | 4 年之前 | |
.eslintrc.json | 4 年之前 | |
CHANGELOG.md | 4 年之前 | |
LICENSE.md | 4 年之前 | |
README.md | 4 年之前 | |
circle.yml | 4 年之前 | |
package.json | 4 年之前 |
sb-scandir
is a node module that supports simple file scanning with some sugar features.
npm install --save sb-scandir
export default function scandir(path: string, recursive: boolean, validate: ((file: string) => boolean)): Promise<{ files: Array<string>, directories: Array<string> }>
import Path from 'path'
import scandir from 'sb-scandir'
// Scan all files except the dot ones
scandir(__dirname).then(function(result) {
console.log('files', result.files)
console.log('directories', result.directories)
})
// Scan all top level files except dot ones
scandir(__dirname, false).then(function(files) {
console.log('files', result.files)
console.log('directories', result.directories)
})
// Scan all files even the dot ones
scandir(__dirname, true, function(path) {
return true
}).then(function(files) {
console.log('files', result.files)
console.log('directories', result.directories)
})
// Scan all files except in .git and node_modules
scandir(__dirname, true, function(path) {
const baseName = Path.basename(path)
return baseName !== '.git' && baseName !== 'node_modules'
}).then(function(files) {
console.log('files', result.files)
console.log('directories', result.directories)
})
This project is licensed under the terms of MIT License. See the LICENSE file for more info.