@@ -10,7 +10,7 @@ const TEST_PATH_REGEX = /\/tests\/(.*?)$/;
10
10
* @param {* } modulePath
11
11
*/
12
12
function getRegexFilter ( modulePath ) {
13
- return MODULE_PATH_REGEXP . exec ( modulePath ) ;
13
+ return MODULE_PATH_REGEXP . exec ( modulePath ) ;
14
14
}
15
15
16
16
/**
@@ -23,7 +23,11 @@ function getRegexFilter(modulePath) {
23
23
*/
24
24
function wildcardFilter ( module , moduleFilter ) {
25
25
// Generate a regular expression to handle wildcard from path filter
26
- const moduleFilterRule = [ '^.*' , moduleFilter . split ( '*' ) . join ( '.*' ) , '$' ] . join ( '' ) ;
26
+ const moduleFilterRule = [
27
+ '^.*' ,
28
+ moduleFilter . split ( '*' ) . join ( '.*' ) ,
29
+ '$' ,
30
+ ] . join ( '' ) ;
27
31
return new RegExp ( moduleFilterRule ) . test ( module ) ;
28
32
}
29
33
@@ -35,7 +39,10 @@ function wildcardFilter(module, moduleFilter) {
35
39
* @param {string } moduleFilter
36
40
*/
37
41
function stringFilter ( modules , moduleFilter ) {
38
- return modules . filter ( module => module . includes ( moduleFilter ) || wildcardFilter ( module , moduleFilter ) ) ;
42
+ return modules . filter (
43
+ ( module ) =>
44
+ module . includes ( moduleFilter ) || wildcardFilter ( module , moduleFilter )
45
+ ) ;
39
46
}
40
47
41
48
/**
@@ -49,7 +56,9 @@ function regexFilter(modules, modulePathRegexFilter) {
49
56
const re = new RegExp ( modulePathRegexFilter [ 2 ] , modulePathRegexFilter [ 3 ] ) ;
50
57
const exclude = modulePathRegexFilter [ 1 ] ;
51
58
52
- return modules . filter ( module => ! exclude && re . test ( module ) || exclude && ! re . test ( module ) ) ;
59
+ return modules . filter (
60
+ ( module ) => ( ! exclude && re . test ( module ) ) || ( exclude && ! re . test ( module ) )
61
+ ) ;
53
62
}
54
63
55
64
/**
@@ -60,7 +69,7 @@ function regexFilter(modules, modulePathRegexFilter) {
60
69
*/
61
70
function convertFilePathToModulePath ( filePath ) {
62
71
const filePathWithNoExtension = filePath . replace ( / \. [ ^ / . ] + $ / , '' ) ;
63
- const testFilePathMatch = TEST_PATH_REGEX . exec ( filePathWithNoExtension ) ;
72
+ const testFilePathMatch = TEST_PATH_REGEX . exec ( filePathWithNoExtension ) ;
64
73
if ( typeof filePath !== 'undefined' && testFilePathMatch !== null ) {
65
74
return testFilePathMatch [ 0 ] ;
66
75
}
@@ -78,26 +87,35 @@ function convertFilePathToModulePath(filePath) {
78
87
*/
79
88
function filterTestModules ( modules , modulePath , filePath ) {
80
89
// Generates an array with module filter value seperated by comma (,).
81
- const moduleFilters = ( filePath || modulePath ) . split ( ',' ) . map ( value => value . trim ( ) ) ;
90
+ const moduleFilters = ( filePath || modulePath )
91
+ . split ( ',' )
92
+ . map ( ( value ) => value . trim ( ) ) ;
82
93
83
94
const filteredTestModules = moduleFilters . reduce ( ( result , moduleFilter ) => {
84
95
const modulePath = convertFilePathToModulePath ( moduleFilter ) ;
85
96
const modulePathRegex = getRegexFilter ( modulePath ) ;
86
97
87
98
if ( modulePathRegex ) {
88
- return result . concat ( regexFilter ( modules , modulePathRegex ) . filter ( module => result . indexOf ( module ) === - 1 ) ) ;
99
+ return result . concat (
100
+ regexFilter ( modules , modulePathRegex ) . filter (
101
+ ( module ) => result . indexOf ( module ) === - 1
102
+ )
103
+ ) ;
89
104
} else {
90
- return result . concat ( stringFilter ( modules , modulePath ) . filter ( module => result . indexOf ( module ) === - 1 ) ) ;
105
+ return result . concat (
106
+ stringFilter ( modules , modulePath ) . filter (
107
+ ( module ) => result . indexOf ( module ) === - 1
108
+ )
109
+ ) ;
91
110
}
92
111
} , [ ] ) ;
93
112
94
113
if ( filteredTestModules . length === 0 ) {
95
- throw new Error ( `No tests matched with the filter: ${ modulePath || filePath } .` ) ;
114
+ throw new Error (
115
+ `No tests matched with the filter: ${ modulePath || filePath } .`
116
+ ) ;
96
117
}
97
118
return filteredTestModules ;
98
119
}
99
120
100
- export {
101
- convertFilePathToModulePath ,
102
- filterTestModules
103
- }
121
+ export { convertFilePathToModulePath , filterTestModules } ;
0 commit comments