Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore patterns starting with ! causes 0 results #63

Closed
Jason3S opened this issue Oct 17, 2024 · 6 comments
Closed

Ignore patterns starting with ! causes 0 results #63

Jason3S opened this issue Oct 17, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@Jason3S
Copy link

Jason3S commented Oct 17, 2024

See: https://codesandbox.io/p/devbox/xr7rqj

import { glob } from "tinyglobby";
import fg from "fast-glob";

async function run() {
  console.log("Run");

  const ignore = ["node_modules", "docs/build/**", "!docs/build/README.md"];

  const resultFG = await fg.glob("**", { ignore });
  const resultTiny = await glob("**", { ignore });

  console.log("%o", { resultFG, resultTiny });
}

run();

Results:

{
  resultFG: [
    'README.md',
    'index.js',
    'package-lock.json',
    'package.json',
    'yarn.lock',
    'docs/README.md',
    'docs/docs-file.txt',
    [length]: 7
  ],
  resultTiny: [ [length]: 0 ]
}

Expected:
Results to be similar to fast-glob.
Note: fast-glob incorrectly removes docs/build/README.md

@SuperchupuDev
Copy link
Owner

i see, will fix. thank you

@SuperchupuDev
Copy link
Owner

i couldn't make it properly work, but it should be consistent with fast-glob now, making this issue solved. can you try it by using the following preview build in your package.json?

  "tinyglobby": "https://pkg.pr.new/tinyglobby@b43ffdf",

@Jason3S
Copy link
Author

Jason3S commented Oct 17, 2024

Thank you very much.

@jdalton
Copy link

jdalton commented Oct 28, 2024

i couldn't make it properly work, but it should be consistent with fast-glob now, making this issue solved.

😢 Ignoring negated patterns is not great. I believe globby supports these. Because this package is named tinyglobby folks might be coming from globby and this difference should definitely be documented.

It means that if any ignore pattern has a ! then the entire ignore option must be set to an empty [] and processed afterwards with something like the ignore package.

@SuperchupuDev
Copy link
Owner

can you show a case where globby produces different results? i thought it didn't support it

@jdalton
Copy link

jdalton commented Oct 28, 2024

Thanks for the quick reply @SuperchupuDev! In digging into this. I looked at the sandbox provided by @Jason3S which does contain a globby compare and it too misses it. I believe the code base I'm on does in fact do the workaround with the ignore() package 🙃. No documentation needed then 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants