Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the deep option does not work #129

Closed
zoubin opened this issue Oct 24, 2018 · 3 comments
Closed

the deep option does not work #129

zoubin opened this issue Oct 24, 2018 · 3 comments
Assignees

Comments

@zoubin
Copy link

zoubin commented Oct 24, 2018

Environment

  • OS Version: macOS 10.13.6
  • Node.js Version: 10.11.0

Actual behavior

When options.deep is set to 1, items with depth 2 are also returned

Expected behavior

Only items with depth less than 2 should be returned

Steps to reproduce

npm i fast-glob
mkdir -p test/fixture/foo
touch test/fixture/foo/index.js
node repro.js

Code sample

repro.js

const fg = require('fast-glob')
fg('test/**/*.js', { deep: 1 }).then(console.log)

More

I believe is due to some lines of code in https://github.com/JS-DevTools/readdir-enhanced/blob/master/lib/directory-reader.js#L187

        if (this.shouldRecurse(stats, posixPath, maxDepthReached)) {
          // Add this subdirectory to the queue
          this.queue.push({
            path: fullPath,
            basePath: itemPath + options.sep,
            posixBasePath: posixPath + '/',
            depth: dir.depth + 1,
          });
        }

        // Determine whether this item matches the filter criteria
        if (this.filter(stats, posixPath)) {
          this.pushOrBuffer({
            data: options.stats ? stats : itemPath,
            file: stats.isFile(),
            directory: stats.isDirectory(),
            symlink: stats.isSymbolicLink(),
          });
        }

Though this.shouldRecurse returns false, this.filter does return true.

@mrmlnc mrmlnc self-assigned this Oct 24, 2018
@mrmlnc
Copy link
Owner

mrmlnc commented Nov 5, 2018

Also related to the #120.

@mrmlnc
Copy link
Owner

mrmlnc commented Nov 5, 2018

Should work correctly after #132. Thanks for report issue 🌮

@mrmlnc mrmlnc closed this as completed Nov 5, 2018
@mrmlnc mrmlnc mentioned this issue Nov 9, 2018
10 tasks
@mrmlnc
Copy link
Owner

mrmlnc commented Nov 9, 2018

Will be shipped at #136.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants