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

Very confused at glob behavior in 5.x vs 4.x #126

Open
dlong500 opened this issue Jul 1, 2020 · 4 comments
Open

Very confused at glob behavior in 5.x vs 4.x #126

dlong500 opened this issue Jul 1, 2020 · 4 comments

Comments

@dlong500
Copy link

dlong500 commented Jul 1, 2020

At first I thought my issues were related to Windows, but I'm experiencing the same behavior in Linux as well (and also using slash to transform any Windows-specific paths).

I've created a test repo here: https://github.com/dlong500/node-cli-base

In my real projects I'm using several types of glob patterns, but the test repo above demonstrates a relatively simple pattern:
/opt/nodejs/node-cli-base/testdata/test?/?

Assuming a testdata folder contents of the following folders:

/opt/nodejs/node-cli-base/testdata/keep/
/opt/nodejs/node-cli-base/testdata/keep/textfile.txt
/opt/nodejs/node-cli-base/testdata/test1/0
/opt/nodejs/node-cli-base/testdata/test1/1
/opt/nodejs/node-cli-base/testdata/test1/2
/opt/nodejs/node-cli-base/testdata/test1/10
/opt/nodejs/node-cli-base/testdata/test1/11
/opt/nodejs/node-cli-base/testdata/test1/12
/opt/nodejs/node-cli-base/testdata/test2/0
/opt/nodejs/node-cli-base/testdata/test2/1
/opt/nodejs/node-cli-base/testdata/test2/2
/opt/nodejs/node-cli-base/testdata/test2/10
/opt/nodejs/node-cli-base/testdata/test2/11
/opt/nodejs/node-cli-base/testdata/test2/12

I would expect the following folders to be deleted:

/opt/nodejs/node-cli-base/testdata/test1/0
/opt/nodejs/node-cli-base/testdata/test1/1
/opt/nodejs/node-cli-base/testdata/test1/2
/opt/nodejs/node-cli-base/testdata/test2/0
/opt/nodejs/node-cli-base/testdata/test2/1
/opt/nodejs/node-cli-base/testdata/test2/2

I get the expected result with del v4.1.1, but no folders are deleted at all with del 5.1.0.

What exactly am I doing wrong? I've read through all the documentation and it doesn't seem like any glob pattern syntax has changed. I've also tried passing extglob: true, onlyFiles: false, and caseSensitiveMatch: false just to see if the behavior changes (even though I believe those are defaults) to no avail.

@dlong500
Copy link
Author

@sindresorhus Can you give any feedback? Either I'm missing something very basic or something is very wrong in the new behavior. If the new behavior is to be expected then it would seem some major documentation changes are in order for how to write glob patterns.

@sindresorhus
Copy link
Owner

This might be related to the following issues:

Just a guess. I don't really have the time to look further into this right now.

@dlong500
Copy link
Author

I still for the life of me can't figure out how to use this library (since v5.x) to accomplish the specific use case above. Namely, to delete content based on a pattern such as /opt/folder?/?. It works with v4.x but not with anything later. The first issue you linked to in fast-glob has been closed, and I don't see how the second one affects my scenario (I'm not trying to match folders at the root). I can't seem to get an even simpler pattern of something like /opt/folder?/file1.txt to work. Using the ? wildcard anywhere except in the basename portion of the path seems to break things.

Can anyone point to a test repo using the latest version of this library where a pattern like /opt/folder?/? or /opt/folder?/file1.txt actually works? This seems like pretty basic glob usage. I'm about to give up and look elsewhere at this point. I could stay with v4.x but then I'm stuck with outdated dependencies.

@dlong500
Copy link
Author

I've tried to do some diagnostics on what might be going on and have now opened the following issue in the glob-parent repo:
gulpjs/glob-parent#39

glob-parent is used by fast-glob so I'm thinking that issue may be the cause of my problems. That is unless I'm completely mistaken about the issue and it somehow is expected behavior (in which case I'm back to square one). Hopefully someone will respond to that issue soon so I can get some useful feedback.

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

No branches or pull requests

2 participants