Skip to content

Glob patterns starting with "*." and having multiple wildcards fails #8817

Closed

Description

@pierre-cm

What version of Bun is running?

1.0.26+c75e768a6

What platform is your computer?

Linux 6.5.0-15-generic x86_64 x86_64

What steps can reproduce the bug?

Considering following project structure:

project/
├ test/
│ └ example.test.ts
├ index.ts
├ package.json
└ tsconfig.json

With following index.ts content:

import { Glob } from "bun"

for await (const f of new Glob('*.test.*').scan({ cwd: "test" })) {
  console.log(f)
}
console.log("done")

What is the expected behavior?

According to Glob API, I would expect the following output:

$ bun run index.ts
example.test.ts
done

What do you see instead?

No file matches the given pattern

$ bun run index.ts
done

Additional information

As a workaround, escaping the first dot seems to work correctly

new Glob('*\\.test.*')

Activity

  1. pierre-cm commented on Feb 9, 2024

    @pierre-cm
    ContributorAuthor

    I suspect the special fast-path matching used for components such as *.ts could be the culprit.
    I believe that including * here might fix the issue.

  2. added
    bun.jsSomething to do with a Bun-specific API
    on Feb 9, 2024
  3. added a commit that references this issue on Feb 11, 2024
    90ea61f
  4. leaumar commented on Feb 13, 2024

    @leaumar

    Just wanna add that escaping the dot doesn't work for me. I'm using 1.0.26 on windows/wsl. Globbing *.md and such in a folder works and lists files, but running the same code with *.* or *\\.* finds no matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingbun.jsSomething to do with a Bun-specific API

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions