Skip to content

Weird behavior with ignore pattern and **/* #343

Closed
@timtim17

Description

Environment

  • OS Version: MacOS Monterrey 12.1
  • Node.js Version: v16.13.0
  • fast-glob: 3.2.7

Actual behavior

aus@Austins-MBP src % node index.js
[ 'foo/bar.txt', 'foo/ignore.txt' ]
[ 'foo/bar.txt', 'test/baz/.not_this_either.txt' ]
[ 'foo/bar.txt' ]

Results A: Works as expected. Gets all txt files, ignoring any in the test directory.
Results B: Does not work as expected. It does correctly give me all text files in the foo folder, except for the ignored ignore.txt, but it also gives me one of (but notably not all) files in the test directory.
Results C: Works as expected, after making a slight change to the ignore option.

Expected behavior

aus@Austins-MBP src % node index.js
[ 'foo/bar.txt', 'foo/ignore.txt' ]
[ 'foo/bar.txt' ]
[ 'foo/bar.txt' ]

Steps to reproduce

  1. See code sample

Code sample

aus@Austins-MBP src % tree -a
.
├── foo
│   ├── bar.txt
│   └── ignore.txt
├── index.js
└── test
    ├── baz
    │   ├── .not_this_either.txt
    │   └── also_no.txt
    └── no.txt

3 directories, 6 files
const fg = require('fast-glob');

const resultsA = fg.sync('**/*.txt', {
    ignore: ['**/test/**/*']
});
console.log(resultsA);

const resultsB = fg.sync('**/!(ignore)*.txt', {
    ignore: ['**/test/**/*']
});
console.log(resultsB);

const resultsC = fg.sync('**/!(ignore)*.txt', {
    ignore: ['**/test/**']
});
console.log(resultsC);

Originally posted by @timtim17 in #329 (comment)

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions