Skip to content

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

@func0der

Description

@func0der

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions