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

Windows globby.sync no longer works for window's paths #130

Closed
k2snowman69 opened this issue Jul 5, 2019 · 8 comments
Closed

Windows globby.sync no longer works for window's paths #130

k2snowman69 opened this issue Jul 5, 2019 · 8 comments

Comments

@k2snowman69
Copy link

k2snowman69 commented Jul 5, 2019

Recently updated from [email protected] -> [email protected] and I've found a difference in execution.

Note that this only happens on Windows. It does not happen on OSX or Linux

9.2.0

let fileList = sync("d:\Temporary\prettier\src***.js");
// fileList.length === 109

10.0.0

let fileList = sync("d:\Temporary\prettier\src***.js");
// fileList.length === 0

Expected:
fileList.length to be 109

@k2snowman69 k2snowman69 changed the title Windows globby.sync no longer works Windows globby.sync no longer works for window's paths Jul 5, 2019
@sindresorhus
Copy link
Owner

Duplicate of #127

@sindresorhus sindresorhus marked this as a duplicate of #127 Jul 6, 2019
@sindresorhus
Copy link
Owner

This is mentioned in the release notes: https://github.com/sindresorhus/globby/releases/tag/v10.0.0

@k2snowman69
Copy link
Author

Where in the release notes? This is all I see:

Breaking:
Upgrade fast-glob package to v3 (#126) 3706920
Important: Read the fast-glob release notes! There are many breaking changes.
Require Node.js 8 9f781ce
Remove /bower_components/ as a default ignore pattern 2dd76d2

Enhancements:
Add globby.stream() (#113) 8aadde8

Fixes:
Fix using the gitignore and stats options together (#121) 33ca01c

@k2snowman69
Copy link
Author

k2snowman69 commented Jul 6, 2019

Ahh you meant here
https://github.com/mrmlnc/fast-glob#pattern-syntax

@k2snowman69
Copy link
Author

Closing issue... will have to determine next steps on my own...

@the-simian
Copy link

If anyone finds this, this is the relevant part: https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows

just using posix alone wasn't good enough, because like when I did path.resolve with __dirname, it gave me a path with mixed / directions on Windows. I had to actually do

.replace(/\\/g, '/') on my final path string to get good results... this particular issue really caught me by surprise

@citrusjunoss
Copy link

citrusjunoss commented Sep 19, 2019

If anyone finds this, this is the relevant part: https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows

just using posix alone wasn't good enough, because like when I did path.resolve with __dirname, it gave me a path with mixed / directions on Windows. I had to actually do

.replace(/\\/g, '/') on my final path string to get good results... this particular issue really caught me by surprise

Can you help me see where there is a problem with usage?

const entriesPath = globby.sync([ path .join(process.cwd(), resolveApp('src') + '/containers/*/index.tsx') .replace(/\\/g, '/'), ]);

This can't find any matching files

@the-simian
Copy link

the-simian commented Sep 19, 2019

'/containers/*/index.tsx' may need to be '/containers/**/index.tsx'

try to glob a specific file first. also you likely want to do the replace on the final path, looks like you've also got like a trailing , and no more glob patterns?

let _path = path .join(process.cwd(), resolveApp('src') + '/containers/*/index.tsx') ;
//console.log(_path)  is this right?? does resolveApp and process.cwd being joined truly work?
_path = _path.replace(/\\/g, '/');
globby.sync(_path);

better suggestion? just use the unixify package!

const glob = require('globby');
const unixify = require('unixify');

function patternToFile(pattern) {
	let _path = unixify(pattern);
	return glob.sync(_path);
}

const files = patternToFile(`./containers/**/index.tsx`);

rivy added a commit to rivy/js.replace-in-files-cli that referenced this issue Oct 6, 2019
rivy added a commit to rivy/js.replace-in-files-cli that referenced this issue Oct 6, 2019
rivy added a commit to rivy/js.replace-in-files-cli that referenced this issue Oct 6, 2019
rivy added a commit to rivy/js.replace-in-files-cli that referenced this issue Nov 15, 2019
jjangga0214 added a commit to awskrug/platform-engineering-glossary that referenced this issue Jan 15, 2024
dirname(import.meta) returns with \ on Windows,
while globby, which uses fast-glob under the hood,
does not treat as path delimiter.
Thus upath is introduced to solve this issue.

REF: sindresorhus/globby#130
REF: https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows
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

4 participants