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

Generated patterns in Windows are incompatible with micromatch #17

Closed
yhatt opened this issue Jun 26, 2019 · 2 comments · Fixed by #18
Closed

Generated patterns in Windows are incompatible with micromatch #17

yhatt opened this issue Jun 26, 2019 · 2 comments · Fixed by #18

Comments

@yhatt
Copy link
Contributor

yhatt commented Jun 26, 2019

dir-glob is using path.join() so it will use \\ as join separator in Windows. It would not compatible with micromatch that reserves backslashes for escaping glob characters.
https://github.com/micromatch/micromatch/#backslashes

It means that the generated glob pattern may not work correctly in Windows environment.

const dirGlob = require('dir-glob')
const micromatch = require('micromatch')

const patterns = dirGlob.sync(['lib'])

console.log(patterns)
console.log(micromatch(['lib/index.js'], patterns))
# POSIX environment
$ node ./test.js
[ 'lib/**' ]
[ 'lib/index.js' ]

# Windows
$ node ./test.js
[ 'lib\\**' ]
[]

I think we should always use slashes to join path by using path.posix.join(), or provide a option to choose how to join.

It came from working in the upgrade of fast-glob in globby's PR: sindresorhus/globby#126 (review)

@sindresorhus
Copy link
Contributor

I agree. Would you be interested in doing a PR?

@yhatt
Copy link
Contributor Author

yhatt commented Jun 26, 2019

Sure. I'm going to work for PR if the suggested way is no problem.

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

Successfully merging a pull request may close this issue.

2 participants