55 * This source code is licensed under the BSD-style license found in the
66 * LICENSE file in the root directory of this source tree. An additional grant
77 * of patent rights can be found in the PATENTS file in the same directory.
8- *
9- * @format
108 */
119'use strict' ;
1210
@@ -19,9 +17,7 @@ if (!process.env.CI_REPO) {
1917 process . exit ( 1 ) ;
2018}
2119if ( ! process . env . GITHUB_TOKEN ) {
22- console . error (
23- 'Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e' ,
24- ) ;
20+ console . error ( 'Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e' ) ;
2521 process . exit ( 1 ) ;
2622}
2723if ( ! process . env . PULL_REQUEST_NUMBER ) {
@@ -96,7 +92,7 @@ var converters = {
9692 } ) ;
9793 } ) ;
9894 } ) ;
99- } ,
95+ }
10096} ;
10197
10298function getShaFromPullRequest ( user , repo , number , callback ) {
@@ -124,6 +120,7 @@ function getFilesFromCommit(user, repo, sha, callback) {
124120 } ) ;
125121}
126122
123+
127124/**
128125 * Sadly we can't just give the line number to github, we have to give the
129126 * line number relative to the patch file which is super annoying. This
@@ -135,7 +132,7 @@ function getLineMapFromPatch(patchString) {
135132 var fileLineIndex = 0 ;
136133 var lineMap = { } ;
137134
138- patchString . split ( '\n' ) . forEach ( line => {
135+ patchString . split ( '\n' ) . forEach ( ( line ) => {
139136 if ( line . match ( / ^ @ @ / ) ) {
140137 fileLineIndex = line . match ( / \+ ( [ 0 - 9 ] + ) / ) [ 1 ] - 1 ;
141138 return ;
@@ -184,27 +181,27 @@ function main(messages, user, repo, number) {
184181 return ;
185182 }
186183
187- getShaFromPullRequest ( user , repo , number , sha => {
188- getFilesFromCommit ( user , repo , sha , files => {
189- files . filter ( file => messages [ file . filename ] ) . forEach ( file => {
190- // github api sometimes does not return a patch on large commits
191- if ( ! file . patch ) {
192- return ;
193- }
194- var lineMap = getLineMapFromPatch ( file . patch ) ;
195- messages [ file . filename ] . forEach ( message => {
196- sendComment ( user , repo , number , sha , file . filename , lineMap , message ) ;
184+ getShaFromPullRequest ( user , repo , number , ( sha ) => {
185+ getFilesFromCommit ( user , repo , sha , ( files ) => {
186+ files
187+ . filter ( ( file ) => messages [ file . filename ] )
188+ . forEach ( ( file ) => {
189+ // github api sometimes does not return a patch on large commits
190+ if ( ! file . patch ) {
191+ return ;
192+ }
193+ var lineMap = getLineMapFromPatch ( file . patch ) ;
194+ messages [ file . filename ] . forEach ( ( message ) => {
195+ sendComment ( user , repo , number , sha , file . filename , lineMap , message ) ;
196+ } ) ;
197197 } ) ;
198- } ) ;
199198 } ) ;
200199 } ) ;
201200}
202201
203202var content = '' ;
204203process . stdin . resume ( ) ;
205- process . stdin . on ( 'data' , function ( buf ) {
206- content += buf . toString ( ) ;
207- } ) ;
204+ process . stdin . on ( 'data' , function ( buf ) { content += buf . toString ( ) ; } ) ;
208205process . stdin . on ( 'end' , function ( ) {
209206 var messages = { } ;
210207
0 commit comments