-
Notifications
You must be signed in to change notification settings - Fork 0
/
match-files.js
42 lines (38 loc) · 1.37 KB
/
match-files.js
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
import mm from 'micromatch'
let PATTERNS = {
filesView: ['**/App/**/view.blocks', '**/DesignSystem/**/view.blocks'],
filesViewLogic: ['**/App/**/logic.js', '**/DesignSystem/**/logic.js'],
filesViewGraphql: ['**/App/**/*.graphql', '**/DesignSystem/**/*.graphql'],
filesViewDataGraphql: [
'**/App/**/data.graphql',
'**/DesignSystem/**/data.graphql',
],
filesViewCustom: ['**/DesignSystem/**/react.js'],
filesFontCustom: [
'**/DesignSystem/Fonts/*.eot',
'**/DesignSystem/Fonts/*.otf',
'**/DesignSystem/Fonts/*.ttf',
'**/DesignSystem/Fonts/*.svg',
'**/DesignSystem/Fonts/*.woff',
'**/DesignSystem/Fonts/*.woff2',
],
}
export let isViewFile = (file) => mm.isMatch(file, PATTERNS.filesView)
export let isViewLogicFile = (file) => mm.isMatch(file, PATTERNS.filesViewLogic)
export let isViewGraphqlFile = (file) =>
mm.isMatch(file, PATTERNS.filesViewGraphql)
export let isViewDataGraphqlFile = (file) =>
mm.isMatch(file, PATTERNS.filesViewDataGraphql)
export let isViewCustomFile = (file) =>
mm.isMatch(file, PATTERNS.filesViewCustom)
export let isFontCustomFile = (file) =>
mm.isMatch(file, PATTERNS.filesFontCustom)
export let MATCH = ['App/**', 'DesignSystem/**']
export function getMatchesPerPattern(files) {
return Object.fromEntries(
Object.entries(PATTERNS).map(([key, match]) => [
key,
new Set(mm(files, match)),
])
)
}