@@ -24,41 +24,38 @@ module.exports = async function ({github, context}, keywords) {
24
24
assigneeNames . push ( assignee . login ) ;
25
25
}
26
26
27
- // test if module keyword is in issue body
28
- const regexModule1 = "### (JASP Module|Is your feature request related to a JASP module\\?)\\s+,*.*(" ;
29
- const regexModule2 = ").*\\s+###" ;
30
- for ( const words of keywords . modules ) {
31
- // create the regex to match with, case insensitive
32
- var regex = new RegExp ( regexModule1 + words [ 0 ] + regexModule2 , "i" ) ;
33
- let found = regex . test ( body ) ;
27
+ // Extract the answer(s) to the module question
28
+ const match = body . match ( / # # # ( J A S P M o d u l e | I s y o u r f e a t u r e r e q u e s t r e l a t e d t o a J A S P m o d u l e \? ) \s * \n + ( .+ ?) \s * ( \n | $ ) / i) ;
34
29
35
- // label and assign someone
36
- if ( found ) {
37
- // checks if there is actually a label specified in the keywords
38
- if ( words [ 1 ] . length > 0 ) {
39
- github . rest . issues . addLabels ( {
40
- issue_number : context . issue . number ,
41
- owner : context . repo . owner ,
42
- repo : context . repo . repo ,
43
- labels : [
44
- words [ 1 ]
45
- ]
46
- } ) ;
47
- }
48
- // checks if there is actually an assignee specified in the keywords
49
- if ( words [ 2 ] . length > 0 ) {
50
- github . rest . issues . addAssignees ( {
51
- issue_number : context . issue . number ,
52
- owner : context . repo . owner ,
53
- repo : context . repo . repo ,
54
- assignees : [
55
- words [ 2 ]
56
- ]
57
- } ) ;
30
+ if ( match && match [ 2 ] ) {
31
+ const rawAnswers = match [ 2 ] . split ( / [ , ; \n ] / ) . map ( ans => ans . trim ( ) . toLowerCase ( ) ) ;
32
+ const uniqueAnswers = [ ...new Set ( rawAnswers ) ] ;
33
+
34
+ for ( const [ keyword , label , assignee ] of keywords . modules ) {
35
+ const keywordLower = keyword . toLowerCase ( ) ;
36
+
37
+ if ( uniqueAnswers . includes ( keywordLower ) ) {
38
+ if ( label ) {
39
+ await github . rest . issues . addLabels ( {
40
+ issue_number : context . issue . number ,
41
+ owner : context . repo . owner ,
42
+ repo : context . repo . repo ,
43
+ labels : [ label ]
44
+ } ) ;
45
+ }
46
+ if ( assignee ) {
47
+ await github . rest . issues . addAssignees ( {
48
+ issue_number : context . issue . number ,
49
+ owner : context . repo . owner ,
50
+ repo : context . repo . repo ,
51
+ assignees : [ assignee ]
52
+ } ) ;
53
+ }
58
54
}
59
55
}
60
56
}
61
57
58
+
62
59
const regexOS1 = "\\#\\#\\# What OS are you seeing the problem on\\?\\s+,*.*(" ;
63
60
const regexOS2 = ").*\\s+\\#\\#\\#" ;
64
61
// test if OS keyword is in issue body
0 commit comments