Skip to content

Releases: thecodrr/fdir

v6.4.3

17 Jan 05:53
Compare
Choose a tag to compare

Fixes

v6.4.2

16 Oct 19:35
Compare
Choose a tag to compare

Fixes

  1. Fix regression where fdir would never resolve when maxDepth was set to < 0 (#127)

v6.4.1

16 Oct 18:33
Compare
Choose a tag to compare

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

30 Sep 07:41
Compare
Choose a tag to compare

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.

Thanks to @43081j in #98

Fixes

Other


New Contributors

Full Changelog: v6.3.0...v6.4.0

6.3.0

25 Aug 13:58
Compare
Choose a tag to compare

Added

  1. withSymlinks now supports the resolvePaths argument again. It was accidentally removed when migrating to TypeScript. Thanks to @SuperchupuDev (#104)

Fixes

  1. Symlink paths no longer end with a leading slash when withSymlinks is enabled.

Other

New Contributors

Full Changelog: v6.2.0...v6.3.0

6.2.0

22 Jul 04:24
Compare
Choose a tag to compare
  1. Updated picomatch peerDependency to v4
  2. Relative paths now work correctly when onlyDirs is enabled.

6.1.1

05 Nov 17:28
Compare
Choose a tag to compare
  1. Fixed issue where consecutive backslashes would get collapsed (#93). (This also fixes crawling of WSL directories on Windows which start with \\wsl.localhost\Ubuntu)
  2. Upgraded picomatch peerDependency requirement to 3.x from 2.x.

6.1.0

13 Aug 18:33
Compare
Choose a tag to compare

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

31 Jul 21:27
Compare
Choose a tag to compare

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

  1. fdir now automatically fallbacks to crawling the current working directory if you pass an empty string as crawl root.
  2. Using withRelativePaths with ./ as root path will now have no effect.

6.0.1

09 Feb 07:48
Compare
Choose a tag to compare
  1. Fixed invalid reference of TypeScript types (#88)

Full Changelog: v6.0.0...v6.0.1