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

Matching failed when adding drive's name in Windows #447

Open
fky2015 opened this issue Jun 18, 2024 · 0 comments
Open

Matching failed when adding drive's name in Windows #447

fky2015 opened this issue Jun 18, 2024 · 0 comments

Comments

@fky2015
Copy link
Contributor

fky2015 commented Jun 18, 2024

Environment

  • OS Version: Windows 11
  • Node.js Version: v22.3.0

Actual && Expected behavior

Question: How to match all the files (e.g. .jpg) in D:/?

For test cases 1 and 2: after adding D:, the matching failed.
For test cases 2 and 7: matching on another drive will success.
For test cases 2 and 4 (or 5 and 6): after adding photos/, the matching will success. (But why?)

It seems it's an unexpected behavior.

// npm install --save fast-glob mock-fs
const fg = require('fast-glob');
const mock = require('mock-fs');

mock({
    'D:/photos/image1.jpg': '',
    'E:/hello/world.txt':'',
    'index.js': '',
})

// 1. correct result: [ 'D:/photos/image1.jpg', 'D:/code/test-glob/index.js' ]
console.log(fg.globSync(['/**/*'], { absolute: true, }));

// 2. unexpected result: [ 'D:/index.js' ]
console.log(fg.globSync(['D:/**/*'], { absolute: true, }));

// 3. unexpected result: [ 'D:/index.js' ]
console.log(fg.globSync(['D:\/**/*'], { absolute: true, }));

// 4. correct result: [ 'D:/photos/**/*' ]
console.log(fg.globSync(['D:/photos/**/*'], { absolute: true, }));

// 5. unexpected result: [ 'D:/index.js' ]
console.log(fg.globSync([fg.convertPathToPattern('D:\\**\\*')], { absolute: true, }));

// 6. correct result: [ 'D:/photos/image1.jpg' ]
console.log(fg.globSync([fg.convertPathToPattern('D:\\photos\\**\\*')], { absolute: true, }));

// 7. correct result: [ 'E:/hello/world.txt' ]
console.log(fg.globSync(['E:/**/*'], { absolute: true, }));
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

1 participant