fast-glob
fast-glob copied to clipboard
Ignore patterns are applied to the absolute path instead of relative to the working directory
Environment
- OS Version: Linux
- Node.js Version: 20.13.1
Actual behavior
[]
Expected behavior
['index.test.js']
Steps to reproduce
- Create a path
~/something/
- Put a file
index.test.js
in there - Run the thing
Code sample
index.ts:
const fg = require('fast-glob');
const include = [ '**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}' ]
const globOptions = {
absolute: true,
ignore: [
'**/something/**',
],
}
const foo = async () => {
return await fg(include, globOptions);
}
foo().then(console.log);
The problem seems to be that the parameter absolute
which is documented as an output control parameter (https://www.npmjs.com/package/fast-glob#output-control) is getting in the way of filtering.
I have not found the correct place in the code yet, but I figure that paths are RESOLVED first and then FILTERED, instead of FILTERED relatively to cwd
first and then RESOLVED to their absolute counterparts.
I hope what I am getting to is clear. Maybe this is intentional behaviour, but i found no documented evidence of that anywhere.