fast-glob icon indicating copy to clipboard operation
fast-glob copied to clipboard

Ignore patterns are applied to the absolute path instead of relative to the working directory

Open func0der opened this issue 1 month ago • 1 comments

Environment

  • OS Version: Linux
  • Node.js Version: 20.13.1

Actual behavior

[]

Expected behavior

['index.test.js']

Steps to reproduce

  1. Create a path ~/something/
  2. Put a file index.test.js in there
  3. 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.

func0der avatar May 18 '24 16:05 func0der