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 don't work in ignore option #86

Open
alexander-akait opened this issue Mar 13, 2018 · 16 comments
Open

Ignore patterns don't work in ignore option #86

alexander-akait opened this issue Mar 13, 2018 · 16 comments
Assignees

Comments

@alexander-akait
Copy link

Environment

  • OS Version: ubuntu 17.10
  • Node.js Version: latest

Actual behavior

Ignore patterns don't work in ignore option.

Expected behavior

Ignore patterns should be work in ignore option. node-glob works perfect.

Steps to reproduce

  1. Create file.txt with any contents.
  2. Create file.yaml with any contents.

Code sample

const fg = require('fast-glob');

fg(['**/*'], {
  absolute: true,
  dot: true,
  ignore: [`!{**/*,*}.txt`],
  onlyFiles: true
})
  .then((entries) => console.log(entries));
@mrmlnc
Copy link
Owner

mrmlnc commented Mar 13, 2018

Hello, @evilebottnawi,

You really want to use negative patterns in the ignore property? Right now you can use positive patterns instead of negative and it's works fine.

@alexander-akait
Copy link
Author

alexander-akait commented Mar 13, 2018

@mrmlnc yes, i have tool which check file contents with extension and report if something wrong, i want get all files exclude some extensions which i don't support. Also '**/*' pattern can be configured by users (i.e. images/**/*).

@mrmlnc
Copy link
Owner

mrmlnc commented Mar 13, 2018

Sounds like a feature request.

JFYI: Right now you can use the following work around:

const fg = require('fast-glob');

await fg(['**/*'], {
  absolute: true,
  dot: true,
  ignore: ['{**/*,*}.txt'], // without !
  onlyFiles: true
})

@mrmlnc mrmlnc added this to the next milestone Mar 13, 2018
@mrmlnc
Copy link
Owner

mrmlnc commented Mar 13, 2018

Just one question:

Why you use the {**/*,*} pattern instead of just a **/*?

As I know, **/* involve * and can be interpreted as «entries with txt extension on any nesting level».

@alexander-akait
Copy link
Author

@mrmlnc yes, any nesting levels. For me it was breaking change, because node-glob support this behavior by default. Workaround glob all files except *.txt, i need vice versa logic.

@reklatsmasters
Copy link

I think this feature related to xojs/xo#65 issue.

@mrmlnc
Copy link
Owner

mrmlnc commented Apr 7, 2018

@reklatsmasters, I think these things are different. Based on the description of this issue – we just want to allow the use ! in the ignore option.

@alexander-akait
Copy link
Author

@reklatsmasters @mrmlnc yep, difference

@mrmlnc mrmlnc closed this as completed Apr 7, 2018
@mrmlnc mrmlnc mentioned this issue Apr 9, 2018
15 tasks
@alexander-akait
Copy link
Author

@mrmlnc problem still exists. Example usage https://github.com/itgalaxy/file-type-lint/blob/master/src/standalone.js#L65.
patterns - {**/*,*}.*

@mrmlnc
Copy link
Owner

mrmlnc commented Apr 23, 2018

@evilebottnawi, you can provide real case with FS structure (ls -R or tree) and actual/expected results?

@mrmlnc mrmlnc reopened this Apr 23, 2018
@alexander-akait
Copy link
Author

alexander-akait commented Apr 23, 2018

@mrmlnc https://github.com/itgalaxy/file-type-lint/tree/master/src/__tests__/fixtures
Using {**/*,*}.* and "ignore: [!{**/*,*}.{svg,jpg,xml,yarml}]" should get all valid*.* files exclude valid.bar and nested/valid.bar

@mrmlnc
Copy link
Owner

mrmlnc commented Apr 29, 2018

So, look like misunderstanding in the issue description :)

I just let you use the negative patterns in the ignore option.

@mikehaertl
Copy link

mikehaertl commented Oct 22, 2020

@mrmlnc Are there any news here? This feature would fix a problem with exclude option in https://github.com/bmewburn/vscode-intelephense (it uses the ignore option of fs-glob).

Use case:

  • intelephense should scan all PHP files in a project directory
  • it should exclude any tests directory below vendor, so it has a default "**/vendor/**/{Tests,tests}/**", as exclude (=fast-glob ignore) option
  • it should not exclude a specific **/vendor/abc/tests directory, so a developer can add "!**/vendor/abc/tests" to exclude

So the full ignore patterns used with fast-glob are:

[
  "**/vendor/**/{Tests,tests}/**",
  "!**/vendor/abc/tests"
]

Without this feature we'd have to list all vendor/xyz/tests directory instead of using vendor/**/tests.

@pbelbin
Copy link

pbelbin commented Jan 27, 2022

@mrmlnc, I too have a situation where we want to use negative ignore patterns to allow certain files to be included in the output, which would otherwise, be excluded due to other ignore patterns. Would be great to see some progress on this!

@mrmlnc
Copy link
Owner

mrmlnc commented Jun 11, 2022

Another issue about this functionality — #356.

Unfortunately, I could not come up with a decent algorithm that allowed me to implement this functionality without completely rewriting the pattern-matching mechanism when reading in depth.

I will try again later, after the major release of this package. Most likely, it's time to reconsider the approach to how we process patterns in the pattern manager and their further application to directories.

I cannot promise any specific dates.

@devinrhode2
Copy link

devinrhode2 commented Jul 14, 2022

Negated patterns would be really nice for a package.json npm script like this:

"format:check:ci:non-ts": "yarn prettier --check '**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}'"

This helps ensure prettier format check is comprehensive, but doesn't repeat what eslint may already be checking.

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

No branches or pull requests

6 participants