sindresorhus / globby

User-friendly glob matching
MIT License
2.52k stars 130 forks source link

There are still duplicates when using non-normalized paths in patterns #119

Closed yannvgn closed 5 years ago

yannvgn commented 5 years ago

Hi Globby maintainers 👋

I'm having troubles when using non-normalized paths in patterns (like ./file.txt).

Let's assume the working directory contains the following files: file1.txt and file2.txt

globby.sync(['*', './file1.txt'])
// returns ['file1.txt', 'file2.txt', './file1.txt']
// where I'm expecting ['file1.txt', 'file2.txt']

I just wanted to raise the issue, though I'm not sure if this is an actual bug or if it's wanted.

Cheers

mrmlnc commented 5 years ago

Most likely this is related to the fast-glob package. Yeap, it's true. We don't use resolved path in the cache for performance reasons (earlier). Right now I don't know we should do it or not.

const fg = require('.');

const entries = fg.sync(['*', './package.json']);

console.log(entries);

result

[                     
  './package.json',   
  'LICENSE',          
  'package-lock.json',
  'package.json',     
  'README.md',        
  'test.js',          
  'tsconfig.json',    
  'tslint.json'       
]                     

Please, move issue to the fast-glob repository.

yannvgn commented 5 years ago

Thanks. I've opened an issue in the fast-glob repo. https://github.com/mrmlnc/fast-glob/issues/190

sindresorhus commented 5 years ago

Closing in favor of https://github.com/mrmlnc/fast-glob/issues/190