thecodrr / fdir

⚡ The fastest directory crawler & globbing library for NodeJS. Crawls 1m files in < 1s
https://thecodrr.github.io/fdir/
MIT License
1.46k stars 51 forks source link

`withSymlinks` doesn't work properly with relative paths on when the symlink is at the top level #113

Open SuperchupuDev opened 3 weeks ago

SuperchupuDev commented 3 weeks ago

the following code behaves differently when you add .withRelativePaths() and a symlink is at the top level. it looks like it just ignores symlinks completely

const b = await new fdir()
  .withSymlinks()
  .exclude(p => p.includes('.git') || p.includes('node_modules'))
  .crawl(process.cwd())
  .withPromise();

b.map(p => console.log(p));

however it works if you crawl path.join(process.cwd(), '..'). using resolvePaths: false as an argument for withSymlinks doesn't solve the issue either

it works perfectly without .withRelativePaths()

SuperchupuDev commented 3 weeks ago

okay, thinking about it it makes sense that withSymlinks doesn't work with relative paths as symlinks can point to anywhere outside the root, as long as useRealPaths is true. if it's false it shouldn't be any hard to process as a relative path