https://github.com/breakroom/tree_walker
Stream based Elixir library to recursively walk through a directory tree
https://github.com/breakroom/tree_walker
elixir filesystem
Last synced: over 1 year ago
JSON representation
Stream based Elixir library to recursively walk through a directory tree
- Host: GitHub
- URL: https://github.com/breakroom/tree_walker
- Owner: breakroom
- License: mit
- Created: 2023-01-07T16:32:41.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-09T16:47:53.000Z (over 3 years ago)
- Last Synced: 2025-01-19T06:48:23.125Z (over 1 year ago)
- Topics: elixir, filesystem
- Language: Elixir
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# TreeWalker
TreeWalker is an Elixir library to recursively walk through directories,
streaming the file paths discovered as it goes.
It can optionally skip directories or return `File.Stat` structs if enabled.
The full documentation is available at .
## Installation
The package can be installed by adding `tree_walker` to your list of
dependencies in `mix.exs`:
```elixir
def deps do
[
{:tree_walker, "~> 0.1.0"}
]
end
```
## Example usages
To find all the `.json` files in a repo, skipping the `.git` directory, you
might do something like:
```elixir
TreeWalker.stream(path, skip_dir: &String.ends_with?(&1, ".git"))
|> Stream.filter(&String.ends_with?(&1, ".json"))
|> Enum.to_list()
```