/
index.ts
49 lines (48 loc) · 1.36 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import matcher from '@pnpm/matcher'
test('matcher()', () => {
{
const match = matcher('*')
expect(match('@eslint/plugin-foo')).toBe(true)
expect(match('express')).toBe(true)
}
{
const match = matcher(['eslint-*'])
expect(match('eslint-plugin-foo')).toBe(true)
expect(match('express')).toBe(false)
}
{
const match = matcher(['*plugin*'])
expect(match('@eslint/plugin-foo')).toBe(true)
expect(match('express')).toBe(false)
}
{
const match = matcher(['a*c'])
expect(match('abc')).toBe(true)
}
{
const match = matcher(['*-positive'])
expect(match('is-positive')).toBe(true)
}
{
const match = matcher(['foo', 'bar'])
expect(match('foo')).toBe(true)
expect(match('bar')).toBe(true)
expect(match('express')).toBe(false)
}
{
const match = matcher(['eslint-*', '!eslint-plugin-bar'])
expect(match('eslint-plugin-foo')).toBe(true)
expect(match('eslint-plugin-bar')).toBe(false)
}
{
const match = matcher(['!eslint-plugin-bar', 'eslint-*'])
expect(match('eslint-plugin-foo')).toBe(true)
expect(match('eslint-plugin-bar')).toBe(true)
}
{
const match = matcher(['eslint-*', '!eslint-plugin-*', 'eslint-plugin-bar'])
expect(match('eslint-config-foo')).toBe(true)
expect(match('eslint-plugin-foo')).toBe(false)
expect(match('eslint-plugin-bar')).toBe(true)
}
})