@@ -64,58 +64,63 @@ module.exports = app => {
64
64
} ) ;
65
65
66
66
app . on ( [ "pull_request.opened" , "pull_request.synchronize" ] , async context => {
67
- const params = context . issue ( ) ;
68
-
69
- let number = context . payload ;
70
- let repo = {
71
- owner : context . payload . repository . name ,
72
- repository : context . payload . repository . owner . login
73
- } ;
74
-
75
- let addChangesetUrl = `${
76
- context . payload . pull_request . head . repo . html_url
77
- } /new/${
78
- context . payload . pull_request . head . ref
79
- } ?filename=.changeset/${ humanId ( {
80
- separator : "-" ,
81
- capitalize : false
82
- } ) } .md`;
83
-
84
- const latestCommitSha = context . payload . pull_request . head . sha ;
85
-
86
- const [ commentId , hasChangeset ] = await Promise . all ( [
87
- // we know the comment won't exist on opened events
88
- // ok, well like technically that's wrong
89
- // but reducing time is nice here so that
90
- // deploying this doesn't cost money
91
- context . payload . action === "synchronize"
92
- ? getCommentId ( context , {
93
- issue_number : number ,
94
- ...repo
95
- } )
96
- : null ,
97
- getChangesetId ( context , {
98
- pull_number : number ,
99
- ...repo
100
- } )
101
- ] ) ;
102
-
103
- let prComment ;
104
- if ( ! hasChangeset ) {
105
- prComment = context . issue ( {
106
- comment_id : commentId ,
107
- body : getAbsentMessage ( latestCommitSha , addChangesetUrl )
108
- } ) ;
109
- } else {
110
- prComment = context . issue ( {
111
- comment_id : commentId ,
112
- body : getApproveMessage ( latestCommitSha , addChangesetUrl )
113
- } ) ;
67
+ try {
68
+ const params = context . issue ( ) ;
69
+
70
+ let number = context . payload ;
71
+ let repo = {
72
+ owner : context . payload . repository . name ,
73
+ repository : context . payload . repository . owner . login
74
+ } ;
75
+
76
+ let addChangesetUrl = `${
77
+ context . payload . pull_request . head . repo . html_url
78
+ } /new/${
79
+ context . payload . pull_request . head . ref
80
+ } ?filename=.changeset/${ humanId ( {
81
+ separator : "-" ,
82
+ capitalize : false
83
+ } ) } .md`;
84
+
85
+ const latestCommitSha = context . payload . pull_request . head . sha ;
86
+
87
+ const [ commentId , hasChangeset ] = await Promise . all ( [
88
+ // we know the comment won't exist on opened events
89
+ // ok, well like technically that's wrong
90
+ // but reducing time is nice here so that
91
+ // deploying this doesn't cost money
92
+ context . payload . action === "synchronize"
93
+ ? getCommentId ( context , {
94
+ issue_number : number ,
95
+ ...repo
96
+ } )
97
+ : null ,
98
+ getChangesetId ( context , {
99
+ pull_number : number ,
100
+ ...repo
101
+ } )
102
+ ] ) ;
103
+
104
+ let prComment ;
105
+ if ( ! hasChangeset ) {
106
+ prComment = context . issue ( {
107
+ comment_id : commentId ,
108
+ body : getAbsentMessage ( latestCommitSha , addChangesetUrl )
109
+ } ) ;
110
+ } else {
111
+ prComment = context . issue ( {
112
+ comment_id : commentId ,
113
+ body : getApproveMessage ( latestCommitSha , addChangesetUrl )
114
+ } ) ;
115
+ }
116
+
117
+ if ( commentId ) {
118
+ return context . github . issues . updateComment ( prComment ) ;
119
+ }
120
+ return context . github . issues . createComment ( prComment ) ;
121
+ } catch ( err ) {
122
+ console . error ( err ) ;
123
+ throw err ;
114
124
}
115
-
116
- if ( commentId ) {
117
- return context . github . issues . updateComment ( prComment ) ;
118
- }
119
- return context . github . issues . createComment ( prComment ) ;
120
125
} ) ;
121
126
} ;
0 commit comments