diff --git a/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts b/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts index 925b498..fcd074a 100644 --- a/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts +++ b/FlowPluginsTs/FlowHelpers/1.0.0/cliUtils.ts @@ -278,20 +278,22 @@ class CLI { // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types let thread: any; - process.on('exit', () => { + const exitHandler = () => { if (thread) { try { - // eslint-disable-next-line no-console + // eslint-disable-next-line no-console console.log('Main thread exiting, cleaning up running CLI'); this.killThread(thread); } catch (err) { - // eslint-disable-next-line no-console + // eslint-disable-next-line no-console console.log('Error running cliUtils on Exit function'); // eslint-disable-next-line no-console console.log(err); } } - }); + }; + + process.on('exit', exitHandler); const cliExitCode: number = await new Promise((resolve) => { try { @@ -334,6 +336,8 @@ class CLI { } }); + process.removeListener('exit', exitHandler); + thread = undefined; if (!this.config.logFullCliOutput) {