Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Releases: thecodrr/fdir

v6.5.0

14 Aug 17:09

Choose a tag to compare

This release brings a lot of cool stuff:

ESM support

fdir now includes esm builds in addition to the commonjs build.

Thanks to @TheAlexLichter in #147

Node v12 support (is back!)

fdir v6.4.6 broke Node v12 & v14 compatibility as it made use of AbortController. We have now replaced AbortController with an in-house solution that should bring back support for Node v12.

Additionally, fdir now has the engines field set to >=12 to make it super clear what versions of Node we support.

Thanks to @SuperchupuDev & @benmccann for bringing this up and helping me test this!

Custom FS

Huge thanks to @43081j for adding support for this. You can now pass a custom FS module and fdir will make use of it instead of the Node.js fs module.

You can use it like so:

    const api = new fdir({
      fs: fakeFs,
    }).crawl("node_modules");

The fs property expects the following methods:

export type FSLike = {
  readdir: typeof nativeFs.readdir;
  readdirSync: typeof nativeFs.readdirSync;
  realpath: typeof nativeFs.realpath;
  realpathSync: typeof nativeFs.realpathSync;
  stat: typeof nativeFs.stat;
  statSync: typeof nativeFs.statSync;
};

Other changes

New Contributors

Full Changelog: v6.4.6...v6.5.0

v6.4.6

10 Jun 07:30

Choose a tag to compare

What's Changed

Full Changelog: v6.4.5...v6.4.6

v6.4.5

28 May 05:07

Choose a tag to compare

What's Changed

  1. Ensure callback is called only once by @thecodrr in #144

Full Changelog: v6.4.4...v6.4.5

v6.4.4

19 Apr 04:41

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v6.4.3...v6.4.4

v6.4.3

17 Jan 05:53

Choose a tag to compare

Fixes

v6.4.2

16 Oct 19:35

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

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

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

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

Choose a tag to compare

  1. Updated picomatch peerDependency to v4
  2. Relative paths now work correctly when onlyDirs is enabled.