-
-
Notifications
You must be signed in to change notification settings - Fork 134
Description
file structure:
.
├── dir
│ ├── .gitignore
│ ├── bar.log
│ └── subdir
│ └── baz.log
└── foo.log
./dir/.gitignore:
*.log
List of files to be excluded by git:
$ git check-ignore ./foo.log ./dir/bar.log ./dir/subdir/baz.log
./dir/bar.log
./dir/subdir/baz.logIf globby works correctly, only the foo.log file should be output:
const globby = require('globby');
(async () => {
const paths = await globby(['**/*.log'], { gitignore: true });
console.log(paths);
// expected: [ 'foo.log' ]
})();However, [email protected] outputs like this:
[ 'foo.log', 'dir/subdir/baz.log' ]The file dir/subdir/baz.log is not excluded!
When [email protected] parses the .gitignore in a subdirectory, it adds the path of the parent to the beginning of each rule:
https://github.com/sindresorhus/globby/blob/v11.0.1/gitignore.js#L18-L24
So, internally, [email protected] has changed the contents of the ./dir/.gitignore file to look like this:
- *.log
+ dir/*.logTherefore, you can avoid this problem by modifying the contents of the ./dir/.gitignore file as follows:
**/*.log
However, this writing style is redundant. Most projects will probably be written in the *.log style.
I believe this is a bug that should be fixed.