A streaming directory traverser for node 4 or greater
npm install directory-tree-stream
The following example demonstrates how to use this module:
const dirTreeStream = require('directory-tree-stream')
const es = require('event-stream')
// Read tree with the directory of this script (__dirname) as root-directory
dirTreeStream(__dirname)
// file.stat contains the fs.Stats object
// file.path contains the path, relative to the root directory
.pipe(es.mapSync((file) => `${file.stat.mode} ${file.path}\n`))
.pipe(process.stdout)
This will generate the following output
16893
16893 subdir
33204 subdir/file.txt
33204 example.js
Creates an instance of stream.Readable that emits all files and directories of a given directory tree (recursively)
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
root | string |
the root directory |
directory-tree-stream
is published under the MIT-license.
See LICENSE.md for details.
For release notes, see CHANGELOG.md
See CONTRIBUTING.md.