@@ -10,7 +10,7 @@ import { promisify } from 'util'
1010const sleep = promisify ( setTimeout ) ;
1111import { build } from 'tsup' ;
1212
13- let isPollingActive = false ;
13+ // let isPollingActive = false;
1414let globalContext : Context ;
1515export const setGlobalContext = ( newContext : Context ) : void => {
1616 globalContext = newContext ;
@@ -217,24 +217,31 @@ export function getRenderViewportsForOptions(options: any): Array<Record<string,
217217}
218218
219219// Global SIGINT handler
220- process . on ( 'SIGINT' , async ( ) => {
221- if ( isPollingActive ) {
222- console . log ( 'Fetching results interrupted. Exiting...' ) ;
223- isPollingActive = false ;
224- } else {
225- console . log ( '\nExiting gracefully...' ) ;
226- }
227- process . exit ( 0 ) ;
228- } ) ;
220+ // process.on('SIGINT', async () => {
221+ // if (isPollingActive) {
222+ // console.log('Fetching results interrupted. Exiting...');
223+ // isPollingActive = false;
224+ // } else {
225+ // console.log('\nExiting gracefully...');
226+ // }
227+ // process.exit(0);
228+ // });
229229
230230// Background polling function
231231export async function startPolling ( ctx : Context , build_id : string , baseline : boolean , projectToken : string ) : Promise < void > {
232+ let filename = '' ;
233+ let isPollingActive = true ;
232234 if ( build_id ) {
235+ filename = `${ build_id } .json`
233236 ctx . log . info ( `Fetching results for buildId ${ build_id } in progress....` ) ;
234237 } else if ( ctx . build && ctx . build . id ) {
238+ if ( ctx . options . fetchResultsFileName ) {
239+ filename = ctx . options . fetchResultsFileName
240+ } else {
241+ filename = `${ ctx . build . id } .json`
242+ }
235243 ctx . log . info ( `Fetching results for buildId ${ ctx . build . id } in progress....` ) ;
236244 }
237- isPollingActive = true ;
238245
239246 const intervalId = setInterval ( async ( ) => {
240247 if ( ! isPollingActive ) {
@@ -244,17 +251,10 @@ export async function startPolling(ctx: Context, build_id: string, baseline: boo
244251
245252 try {
246253 let resp ;
247- let filename ;
248254 if ( build_id ) {
249255 resp = await ctx . client . getScreenshotData ( build_id , baseline , ctx . log , projectToken ) ;
250- filename = `${ build_id } .json`
251256 } else if ( ctx . build && ctx . build . id ) {
252257 resp = await ctx . client . getScreenshotData ( ctx . build . id , ctx . build . baseline , ctx . log , '' ) ;
253- if ( ctx . options . fetchResultsFileName ) {
254- filename = ctx . options . fetchResultsFileName
255- } else {
256- filename = `${ ctx . build . id } .json`
257- }
258258 } else {
259259 return ;
260260 }
0 commit comments