Skip to content

Commit d77ba4b

Browse files
authored
Merge pull request #179 from bcomnes/fix-star-matches
add tests for double stars
2 parents d808b08 + 8f4e377 commit d77ba4b

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

lib/match-tasks.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
// Requirements
1111
// ------------------------------------------------------------------------------
1212

13-
const { minimatch } = require('minimatch')
14-
const Minimatch = minimatch.Minimatch
13+
const picomatch = require('picomatch')
1514

1615
// ------------------------------------------------------------------------------
1716
// Helpers
@@ -21,7 +20,7 @@ const COLON_OR_SLASH = /[:/]/g
2120
const CONVERT_MAP = { ':': '/', '/': ':' }
2221

2322
/**
24-
* Swaps ":" and "/", in order to use ":" as the separator in minimatch.
23+
* Swaps ":" and "/", in order to use ":" as the separator in picomatch.
2524
*
2625
* @param {string} s - A text to swap.
2726
* @returns {string} The text which was swapped.
@@ -44,8 +43,10 @@ function createFilter (pattern) {
4443
const spacePos = trimmed.indexOf(' ')
4544
const task = spacePos < 0 ? trimmed : trimmed.slice(0, spacePos)
4645
const args = spacePos < 0 ? '' : trimmed.slice(spacePos)
47-
const matcher = new Minimatch(swapColonAndSlash(task), { nonegate: true })
48-
const match = matcher.match.bind(matcher)
46+
const match = picomatch(swapColonAndSlash(task), {
47+
nonegate: true,
48+
strictSlashes: true,
49+
})
4950

5051
return { match, task, args }
5152
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"ansi-styles": "^6.2.1",
3535
"cross-spawn": "^7.0.6",
3636
"memorystream": "^0.3.1",
37-
"minimatch": "^10.0.1",
37+
"picomatch": "^4.0.2",
3838
"pidtree": "^0.6.0",
3939
"read-package-json-fast": "^4.0.0",
4040
"shell-quote": "^1.7.3",

test/pattern.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,24 @@ describe('[pattern] it should run matched tasks if glob like patterns are given.
5050
})
5151
})
5252

53+
describe('"test-task:append:**" to "test-task:append:a", "test-task:append:a:c", "test-task:append:a:d", and "test-task:append:b"', () => {
54+
it('Node API', async () => {
55+
await nodeApi('test-task:append:**')
56+
assert(result() === 'aaacacadadbb')
57+
})
58+
59+
it('npm-run-all command', async () => {
60+
await runAll(['test-task:append:**'])
61+
assert(result() === 'aaacacadadbb')
62+
})
63+
64+
it('run-s command', async () => {
65+
await runSeq(['test-task:append:**'])
66+
assert(result() === 'aaacacadadbb')
67+
})
68+
})
69+
70+
// should act same way as section above
5371
describe('"test-task:append:**:*" to "test-task:append:a", "test-task:append:a:c", "test-task:append:a:d", and "test-task:append:b"', () => {
5472
it('Node API', async () => {
5573
await nodeApi('test-task:append:**:*')

0 commit comments

Comments
 (0)