@@ -103,12 +103,7 @@ async function generateCypressBuildReport(report_data) {
103103 logger . debug ( "Creating results directory." ) ;
104104 fs . mkdirSync ( resultsDir ) ;
105105 }
106- getReportResponse ( resultsDir , 'report.zip' , report_data . cypress_custom_report_url ) . then ( ( message ) => {
107- logger . debug ( message ) ;
108- } ) . catch ( ( errorMessage ) => {
109- logger . error ( errorMessage ) ;
110- process . exitCode = Constants . ERROR_EXIT_CODE ;
111- } ) ;
106+ await getReportResponse ( resultsDir , 'report.zip' , report_data . cypress_custom_report_url ) ;
112107}
113108
114109function getReportResponse ( filePath , fileName , reportJsonUrl ) {
@@ -129,19 +124,16 @@ function getReportResponse(filePath, fileName, reportJsonUrl) {
129124 writer . on ( 'error' , err => {
130125 error = err ;
131126 writer . close ( ) ;
127+ process . exitCode = Constants . ERROR_EXIT_CODE ;
132128 reject ( err ) ;
133129 } ) ;
134130 writer . on ( 'close' , async ( ) => {
135131 if ( ! error ) {
136132 logger . debug ( "Unzipping downloaded html and json reports." ) ;
137- unzipFile ( filePath , fileName ) . then ( ( message ) => {
138- logger . debug ( message ) ;
139- } ) . catch ( ( err ) => {
140- logger . debug ( `Unzipping html and json report failed. Error: ${ err } ` ) ;
141- } ) ;
133+ await unzipFile ( filePath , fileName ) ;
142134 fs . unlinkSync ( tmpFilePath ) ;
143- let message = "Successfully prepared json and html reports." ;
144- resolve ( message ) ;
135+ logger . debug ( "Successfully prepared json and html reports." ) ;
136+ resolve ( true ) ;
145137 }
146138 //no need to call the reject here, as it will have been called in the
147139 //'error' stream;
@@ -154,11 +146,14 @@ function getReportResponse(filePath, fileName, reportJsonUrl) {
154146const unzipFile = async ( filePath , fileName ) => {
155147 return new Promise ( async ( resolve , reject ) => {
156148 await unzipper . Open . file ( path . join ( filePath , fileName ) )
157- . then ( ( d ) => {
158- d . extract ( { path : filePath , concurrency : 5 } ) ;
159- } ) . catch ( ( err ) => reject ( err ) ) ;
160- let message = "Unzipped the json and html successfully."
161- resolve ( message ) ;
149+ . then ( d => d . extract ( { path : filePath , concurrency : 5 } ) )
150+ . catch ( ( err ) => {
151+ logger . debug ( `Unzipping html and json report failed. Error: ${ err } ` ) ;
152+ process . exitCode = Constants . ERROR_EXIT_CODE ;
153+ reject ( err ) ;
154+ } ) ;
155+ logger . debug ( "Unzipped the json and html successfully." )
156+ resolve ( ) ;
162157 } ) ;
163158}
164159
0 commit comments