-
-
Notifications
You must be signed in to change notification settings - Fork 482
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 paths normalized to forward slashes, not platform-native backslashes #419
Comments
I ran into this too. Node's |
On version 7.1.7: glob('/**') //= absolute with backslashes
glob('**') //= relative with forward slashes
glob('**', { realpath: true }) //= absolute with backslashes
glob('**', { absolute: true }) //= absolute with forward slashes What is going on It seems that tiny-glob works mostly the same and solves this issue, always returning native separators (unless you use an absolute path glob). |
Due to an error in how node-glob returns paths, a specific option is required in order to return paths appropriately for each platform. See: isaacs/node-glob#419 Fixes: mmazzarolo/react-native-universal-monorepo#12
Due to an error in how node-glob returns paths, a specific option is required in order to return paths appropriately for each platform. See: isaacs/node-glob#419 Fixes: mmazzarolo/react-native-universal-monorepo#12
I'm pretty sure 8 resolves this by normalizing everything to forward slashes? Unless anyone disagrees, I am so incredibly happy to close this issue. |
Yep, that was the intent. Closing! |
I use |
You can also use the const results = (await glob('./**/*.ts', { withFileTypes: true })).map(p => p.relativePosix()) |
Thanks, it is a more elegant method for doing this. 😄 |
Description of issue
As many folks are aware, much of the world has sandardized on forward slashes as path / folder delimiters (eg
/path/to/your/file.txt
orhttps://domain.com/path/to/your/view
).Windows, however, has historically relied on backslashes (eg
C:\path\to\your\file.txt
).Node, of course, respects both per-platform:
console.log(process.cwd()) // /path/to/current/folder
console.log(process.cwd()) // C:\\path\\to\\current\\folder
When
node-glob
returns results on Windows, it outputs them with forward slash-normalized paths. This can cause cross-platform compatibility problems.Example:
In Windows, the above code would not work, as using methods intended to ease cross platform compatibility (like
path.sep
) break withnode-glob
's forward-slash normalized output.Expected behavior
Repro steps
process.cwd()
, etc. in Windows; file Node presents backslash-normalized file pathsThe text was updated successfully, but these errors were encountered: