Open alexander-akait opened 6 years ago
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.
@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/**/*
).
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
})
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».
@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.
I think this feature related to xojs/xo#65 issue.
@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.
@reklatsmasters @mrmlnc yep, difference
@mrmlnc problem still exists. Example usage https://github.com/itgalaxy/file-type-lint/blob/master/src/standalone.js#L65
.
patterns
- {**/*,*}.*
@evilebottnawi, you can provide real case with FS structure (ls -R
or tree
) and actual/expected results?
@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
So, look like misunderstanding in the issue description :)
I just let you use the negative patterns in the ignore
option.
@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:
tests
directory below vendor
, so it has a default "**/vendor/**/{Tests,tests}/**",
as exclude
(=fast-glob ignore
) option**/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
.
@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!
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.
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.
Environment
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
file.txt
with any contents.file.yaml
with any contents.Code sample