Skip to content

Corner case when globbing current directory returns zero results #92

Closed
@bglw

Description

@bglw

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.

  • Removing .withBasePath() causes the files to be found
  • Removing the glob(...) causes all files in the current directory to be found.
    • I haven't found a glob that will return any results, including a more explicit ./**/*.txt
  • Changing the path to crawler.crawl("content") or crawler.crawl(process.cwd()) causes the files to be found
    • "./" also does not work as the directory

I'm on an M1 Macbook, for reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions