Skip to content

Releases: thecodrr/fdir

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

6.0.0

08 Feb 18:24
Compare
Choose a tag to compare

Note: While fdir tries to strictly follow semver, this release doesn't actually break anything. It does deprecate a few things but overall, migrating from v5.3.0 to v6.0.0 should be seamless.

⭐ Features & new stuff

Typescript rewrite

fdir has now been fully rewritten in TypeScript. This brings better clarity into what's happening and how its happening. The code in the project has also be reorganized & broken down so it's much easier to understand now.

Another benefit of using TypeScript is types. Since everything is now autogenerated by tsc, it is always in sync with the actual API. With the help of generics, the output type is now automatically inferred based on the method used. That means no more as string[] etc.

globWithOptions

Globbing support has always been barebones in fdir. This release brings in full support for passing picomatch options when globbing. Use it like this:

new fdir()
  .globWithOptions(["**/*.js"], { dot: true })
  .crawl("path/to/dir")
  .sync();

⚔️ Deprecations

A lot of unintuitive & badly designed API choices have been deprecated. They will continue to work as intended but they will eventually be removed in the upcoming major versions. These include:

crawlWithOptions

This function was added as a convenience for people who don't like the Builder API. This has now been replaced with the fdir constructor.

Instead of this:

new fdir()
  .crawlWithOptions("./", { includeDirs: true })
  .sync();

You should now do this:

new fdir({ includeDirs: true })
  .crawl("./")
  .sync();

P.S. I forgot to deprecate includeDirs and replace it with includeDirectories. Oh well, I'll do that in the next version.

directories instead of dirs

When using the onlyCounts() API, the resulting object will now contain directories instead of dirs. A minor change but I really don't like abbreviations unless absolutely necessary.

directory instead of dir

When using the group() API, the resulting object will now contain directory instead of dir.


And that's it. No other changes to the API. I am pretty sure that the TypeScript rewrite fixed some hidden & hard-to-debug bugs so you should find v6.0.0 much more stable.