@hoge1e3/bottomup
A bottom-up directory traversal utility that yields files ordered by their last update time. Designed to work with @hoge1e3/sfile
's SFile
API.
Features
- Traverses directories recursively
- Sorts files by recent modification (most recent first)
- Skips excluded files and folders based on pattern or function
- Optionally moves up to parent directories
Installation
npm install @hoge1e3/bottomup
Usage
import bottomup from "@hoge1e3/bottomup";
import { SFile } from "@hoge1e3/sfile";
const root = SFile.get("./some/dir");
for (const file of bottomup(root, {
excludes: [/node_modules/, "dist"]
})) {
console.log(file.path());
}
API
bottomup(dir: SFile, opt?: DirectoryOptions): Generator<SFile>
dir
: Root directory to start traversalopt.excludes
: A string, regex, function, or array of these used to skip files/dirs
License
MIT