Skip to content

Repository files navigation

node-walkdir

node traversal files (async/sync)

Linux BuildCoverage StatusDependenciesnodelicense MIT

中文文档

Requirements

node8 or higher

How to use it

Installation

$ yarn add node-walkdir
# or
$ npm install node-walkdir

Examples

constwalkdir=require('node-walkdir')/** async */(async()=>{// walk all files by defaultconstallFiles=awaitwalk('you-path');console.log('files:',allFiles);// only traverse the JS filesconstjsFiles=awaitwalk('you-path','.js');console.log('files:',jsFiles);// traverse the JS and JSON filesconstjsonFiles=awaitwalk('you-path',['.js','.json']);console.log('files:',jsonFiles);// traverse the JS and JSON files by regexpconstjson2Files=awaitwalk('you-path',/\.js(on)?$/);console.log('files:',json2Files);// only traverse the JS files with 2 level directories deep.constjs2Files=awaitwalk('you-path','.js',2);console.log('files:',js2Files);})();/** sync */// walk all files by defaultconstallFiles=walk.sync('you-path');console.log('files:',allFiles);// only traverse the JS filesconstjsFiles=walk.sync('you-path','.js');console.log('files:',jsFiles);// traverse the JS and JSON filesconstjsonFiles=walk.sync('you-path',['.js','.json']);console.log('files:',jsonFiles);// traverse the JS and JSON files by regexpconstjson2Files=walk.sync('you-path',/\.js(on)?$/);console.log('files:',json2Files);// only traverse the JS files with 2 level directories deep.constjs2Files=walk.sync('you-path','.js',2);console.log('files:',js2Files);

About

node traversal files (async/sync)

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages