Releases: thecodrr/fdir
v6.4.3
v6.4.2
v6.4.1
Fixes
Recursive symlinks handling (#125)
Previously, fdir left it up to the OS to handle recursive symlinks. Unfortunately, this resulted in an infinite loop that'd either cause a crash or take too long to resolve (each OS has a different limit on resolving recursive symlinks). This has been fixed now in #126.
Recursive symlinks with resolvePaths: true
When resolvePaths
is set to true
, fdir
does not crawl a directory it has already visited. To figure out whether we have visited a directory or not, fdir
maintains a list of all the directories it has visited. This might result in slightly higher memory usage than before.
For a directory that looks like this:
/dir/
file
symlink -> /dir/
fdir will return:
[ "/dir/file" ]
In short, you won't see duplicated paths in the output which is the expected behavior when working with file systems since paths are unique.
Recursive symlinks with resolvePaths: false
When you set resolvePaths
to false
, the behavior differs because now all symlinks become part of the path.
For a directory that looks like this:
/dir/
file
symlink -> /dir/
fdir will return:
[ "/dir/file", "/dir/symlink/file" ]
To prevent recursion, all recursive symlinks are only resolved a single level deep making sure you never see something like /dir/symlink/symlink/symlink/file
. This allows for glob patterns to work with recursive symlinks without creating a performance issue.
Relative recursive symlinks
Relative recursive symlinks work exactly as above except the returned paths are relative to the root. Everything else is exactly the same.
Thanks to @SuperchupuDev for bringing this to my attention.
v6.4.0
Features
Exclude symlinks
You can now specifically exclude symlinks from the crawling process. Here's how you can do that:
new fdir({ excludeSymlinks: true }).crawl().sync();
Thanks to @SuperchupuDev in #115
Custom glob functions
Previously, fdir only supported picomatch
for globbing disallowing any customization in this area. While that worked really well for most people, it wasn't super flexible. Starting from this version, fdir supports changing the default glob function:
// using a custom function
const customGlob = (patterns: string | string[]) => {
return (test: string): boolean => test.endsWith('.js');
};
const crawler = new fdir().withGlobFunction(customGlob).globWithOptions("**/*.js");
withGlobFunction
accepts a glob
factory function which you can use to perform intensive work only once. For example, picomatch
provides a glob factory that optimizes and preprocesses your glob patterns increasing match significantly.
Fixes
- Support symlinks with relative paths enabled by @SuperchupuDev in #114
- Do not return an empty string for the root by @SuperchupuDev in #123
Other
- Add Video Hub App to "Used by" section of README by @whyboris in #121
- docs: update symlinks support by @SuperchupuDev in #119
- chore(deps): bump vite from 5.0.2 to 5.4.8 by @dependabot in #117
- chore(deps): bump braces from 3.0.2 to 3.0.3 by @dependabot in #118
- docs: list more packages using
fdir
by @benmccann in #112
New Contributors
- @benmccann made their first contribution in #112
- @43081j made their first contribution in #98
- @whyboris made their first contribution in #121
Full Changelog: v6.3.0...v6.4.0
6.3.0
Added
withSymlinks
now supports theresolvePaths
argument again. It was accidentally removed when migrating to TypeScript. Thanks to @SuperchupuDev (#104)
Fixes
- Symlink paths no longer end with a leading slash when
withSymlinks
is enabled.
Other
- chore: exclude irrelevant files from published bundle by @SuperchupuDev in #105
- fix(docs): remove Immich CLI by @etnoy in #108
- docs: document missing options by @SuperchupuDev in #110
- chore: fix import in benchmark scripts by @SuperchupuDev in #111
New Contributors
Full Changelog: v6.2.0...v6.3.0
6.2.0
6.1.1
6.1.0
withPathSeparator(separator: "/" | "\")
🆕
withPathSeparator
option allows you enforcing a specific path separator regardless of what platform the code is running on. This is especially useful if your test snapshots contain paths as those snapshots will fail on Windows because Node.js uses \\
path separator on Windows by default.
For example:
const files = await new fdir().withFullPaths().withPathSeparator("/").crawl("node_modules").withPromise();
6.0.2
More reliable globbing
This release contains a lot of fixes for glob
making it much more reliable. (thanks to @bglw for reporting a reproducible test case #92)
For example, doing this would return an empty array:
const crawler = new fdir().withBasePath().glob("**/*.txt");
const files = await crawler.crawl(".").withPromise();
This was because picomatch
and other globbing libraries don't deal too well with paths that start with .
or ./
. Starting from this version, fdir
tries very hard to not include ./
or .
at the beginning of the paths.
The end result is that fdir
should now work similar to fast-glob
and other globbing libraries.
Node v20 support
Starting from this version, fdir
now officially supports Node v20 with all its tests running on it.
Other fixes
fdir
now automatically fallbacks to crawling the current working directory if you pass an empty string as crawl root.- Using
withRelativePaths
with./
as root path will now have no effect.