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

Support for Relative Paths?

Open alexander-alvarez opened this issue 7 years ago • 1 comments

Environment

  • OS Version: Ubuntu 16.04
  • Node.js Version: v8.9.4

Actual behavior

Relative paths add files, but glob ignores do not match those files for some reason.

For the record node-glob behaves the same as this (https://github.com/isaacs/node-glob/compare/master...alexander-alvarez:relative-paths) fails tests

/*
fixtures:
a/
 - foo.md
b/
 - foo.js
*/

fg(['../a/**', { cwd: 'b', ignore: '*.md'});
// yields
['../a/foo.md']

Expected behavior

[] since the file is ignored.

Steps to reproduce

See above

alexander-alvarez avatar Jul 03 '18 19:07 alexander-alvarez

@mrmlnc I'm interesting in this too. This can allow to point to modules outside of the monorepo in pnpm: https://github.com/pnpm/pnpm/blob/v4.11.5/packages/find-packages/src/index.ts#L34

Bessonov avatar Mar 13 '20 21:03 Bessonov

FG understands that the ../a/** pattern has a parent directory (../a) and starts searching for files in the b/../a directory. All found entries have the prefix of the original pattern (../a, eg ../a/foo.md). Then negative patterns are applied. When you specify the *.md pattern in the ignore option, it is applied to the found entries without changes.

The simple negative pattern *.md (matches only one level) cannot be applied to the more complex ../a/foo.md.

I can't imagine what it would look like in code and I don't know of any solution that supports such behaviour (maybe you know?).

My current vision for the development of this package does not involve adding this functionality. I am ready to return to the discussion if any products supporting such behavior are provided.

mrmlnc avatar Apr 30 '23 10:04 mrmlnc