@@ -103,12 +103,7 @@ async function generateCypressBuildReport(report_data) {
103
103
logger . debug ( "Creating results directory." ) ;
104
104
fs . mkdirSync ( resultsDir ) ;
105
105
}
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 ) ;
112
107
}
113
108
114
109
function getReportResponse ( filePath , fileName , reportJsonUrl ) {
@@ -129,19 +124,16 @@ function getReportResponse(filePath, fileName, reportJsonUrl) {
129
124
writer . on ( 'error' , err => {
130
125
error = err ;
131
126
writer . close ( ) ;
127
+ process . exitCode = Constants . ERROR_EXIT_CODE ;
132
128
reject ( err ) ;
133
129
} ) ;
134
130
writer . on ( 'close' , async ( ) => {
135
131
if ( ! error ) {
136
132
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 ) ;
142
134
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 ) ;
145
137
}
146
138
//no need to call the reject here, as it will have been called in the
147
139
//'error' stream;
@@ -154,11 +146,14 @@ function getReportResponse(filePath, fileName, reportJsonUrl) {
154
146
const unzipFile = async ( filePath , fileName ) => {
155
147
return new Promise ( async ( resolve , reject ) => {
156
148
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 ( ) ;
162
157
} ) ;
163
158
}
164
159
0 commit comments