thecodrr / fdir

⚡ The fastest directory crawler & globbing library for NodeJS. Crawls 1m files in < 1s
https://thecodrr.github.io/fdir/
MIT License
1.46k stars 51 forks source link

Corner case when globbing current directory returns zero results #92

Closed bglw closed 1 year ago

bglw commented 1 year ago

I have a weird case narrowed down where using a glob, a crawl path of ., and the withBasePath option together causes no results to be returned.

Reproduction setup:

npm init -y
npm pkg set type="module"
npm i fdir picomatch

mkdir content
touch content/file1.txt
touch content/file2.txt

Reproduction js:

import { fdir } from "fdir";

const run = async () => {
  const crawler = new fdir().withBasePath();
  crawler.glob("**/*.txt");
  const files = await crawler.crawl(".").withPromise();
  console.log(files);
};

run();

This will log out (on my machine) [].

This only occurs when all three options are configured as so.

I'm on an M1 Macbook, for reference.

thecodrr commented 1 year ago

Hi, thanks for reporting this issue! I will take a look at this ASAP.