File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,8 +10,20 @@ const githubToken = process.env.GH_TOKEN;
1010const countAllCommits = process . env . ALL_COMMITS . toString ( ) === 'true' ;
1111
1212async function main ( ) {
13- const stats = await getStats ( ) ;
14- await updateGist ( stats ) ;
13+ if ( ! githubToken ) {
14+ throw new Error ( 'GH_TOKEN is not defined' ) ;
15+ }
16+ let stats ;
17+ try {
18+ stats = await getStats ( ) ;
19+ } catch ( e ) {
20+ throw new Error ( `cannot retrieve statistics: ${ e . message } ` ) ;
21+ }
22+ try {
23+ await updateGist ( stats ) ;
24+ } catch ( e ) {
25+ throw new Error ( `cannot update gist: ${ e . message } ` ) ;
26+ }
1527}
1628
1729async function getStats ( ) {
@@ -86,8 +98,7 @@ async function updateGist(stats) {
8698 } ) ;
8799}
88100
89- ( async ( ) => {
90- await main ( ) . catch ( ( err ) => {
91- console . error ( err ) ;
92- } ) ;
93- } ) ( ) ;
101+ main ( ) . catch ( ( err ) => {
102+ console . error ( err . message ) ;
103+ process . exit ( 1 ) ;
104+ } ) ;
You can’t perform that action at this time.
0 commit comments