Skip to content

Commit 777e4d3

Browse files
committedFeb 17, 2022
fix: normalize backslashes
The next semver-major of minimatch does not allow backslashes. We'll normalize it here so that change doesn't break anyone currently relying on that behavior.
1 parent e441074 commit 777e4d3

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
 

‎lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function pkgPathmame (opts) {
5656

5757
// make sure glob pattern only matches folders
5858
function getGlobPattern (pattern) {
59+
pattern = pattern.replace(/\\/g, '/')
5960
return pattern.endsWith('/')
6061
? pattern
6162
: `${pattern}/`

‎tap-snapshots/test/test.js.test.cjs

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
* Make sure to inspect the output below. Do not ignore changes!
66
*/
77
'use strict'
8+
exports[`test/test.js TAP backslashes are normalized > matches with backslashes 1`] = `
9+
Map {
10+
"a" => "{CWD}/test/tap-testdir-test-backslashes-are-normalized/packages/a",
11+
}
12+
`
13+
814
exports[`test/test.js TAP double negate patterns > should include doubly-negated items into resulting map 1`] = `
915
Map {
1016
"a" => "{CWD}/test/tap-testdir-test-double-negate-patterns/packages/a",

‎test/test.js

+22
Original file line numberDiff line numberDiff line change
@@ -771,3 +771,25 @@ test('try to declare node_modules', t => {
771771
'should not include declared packages within node_modules'
772772
)
773773
})
774+
775+
test('backslashes are normalized', t => {
776+
const cwd = t.testdir({
777+
packages: {
778+
a: {
779+
'package.json': '{ "name": "a" }',
780+
},
781+
},
782+
})
783+
784+
return t.resolveMatchSnapshot(
785+
mapWorkspaces({
786+
cwd,
787+
pkg: {
788+
workspaces: [
789+
'packages\\*',
790+
],
791+
},
792+
}),
793+
'matches with backslashes'
794+
)
795+
})

0 commit comments

Comments
 (0)
Please sign in to comment.