@@ -24,7 +24,7 @@ if (!isNaN(terminalWidth)) lineSeparator = "\n" + "-".repeat(terminalWidth);
2424
2525let getOptions = ( auth , build_id ) => {
2626 return {
27- url : `${ config . buildUrl } ${ build_id } ` ,
27+ url : `${ config . buildUrlV2 } ${ build_id } ` ,
2828 auth : {
2929 user : auth . username ,
3030 password : auth . access_key
@@ -144,18 +144,31 @@ let whileProcess = (whilstCallback) => {
144144
145145 whileTries = config . retries ; // reset to default after every successful request
146146
147+ console . log ( `---> response code: ${ response . statusCode } body is: ${ JSON . stringify ( body ) } ` )
147148 switch ( response . statusCode ) {
148149 case 202 : // get data here and print it
149150 n = 2
150- showSpecsStatus ( body ) ;
151+ // try {
152+ // parsed_body = JSON.parse(JSON.stringify(body));
153+ // showSpecsStatus(parsed_body['data']);
154+ // } catch (error) {
155+ // console.log(`---> Got error: ${JSON.stringify(error)}`)
156+ // }
157+ showSpecsStatus ( body , 202 ) ;
151158 return setTimeout ( whilstCallback , timeout * n , null ) ;
152159 case 204 : // No data available, wait for some time and ask again
153160 n = 1
154161 return setTimeout ( whilstCallback , timeout * n , null ) ;
155162 case 200 : // Build is completed.
156163 whileLoop = false ;
157164 endTime = Date . now ( ) ;
158- showSpecsStatus ( body ) ;
165+ // try {
166+ // parsed_body = JSON.parse(body);
167+ // showSpecsStatus(JSON.stringify(parsed_body['data']));
168+ // } catch (error) {
169+ // console.log(`---> Got error: ${JSON.stringify(error)}`)
170+ // }
171+ showSpecsStatus ( body , 200 ) ;
159172 return specSummary . exitCode == Constants . BUILD_FAILED_EXIT_CODE ?
160173 whilstCallback ( { status : 204 , message : "No specs ran in the build" } ) : whilstCallback ( null , body ) ;
161174 default :
@@ -169,9 +182,9 @@ let getStackTraceUrl = () => {
169182 return specSummary . buildError
170183}
171184
172- let showSpecsStatus = ( data ) => {
185+ let showSpecsStatus = ( data , statusCode ) => {
173186 let specData = JSON . parse ( data ) ;
174- specData . forEach ( specDetails => {
187+ specData [ "specDetails" ] . forEach ( specDetails => {
175188 if ( specDetails . type === Constants . CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY ) {
176189 addCustomErrorToPrint ( specDetails ) ;
177190 } else {
@@ -190,6 +203,14 @@ let showSpecsStatus = (data) => {
190203 }
191204 }
192205 } ) ;
206+ if ( statusCode != 200 ) return ;
207+ // Below block is for printing build details, return if non 200 status code
208+ if ( "buildDetails" in specData ) {
209+ const buildDetails = specData [ "buildDetails" ] ;
210+ logger . info ( `Done in ${ buildDetails [ "duration" ] } seconds with ${ buildDetails [ "parallels" ] } parallels.\n` ) ;
211+ } else {
212+ logger . debug ( `Build details not sent` )
213+ }
193214}
194215
195216let printInitialLog = ( ) => {
0 commit comments