diff --git a/packages/nx/bin/init-local.ts b/packages/nx/bin/init-local.ts index 1a6b157fd6..363b77c12c 100644 --- a/packages/nx/bin/init-local.ts +++ b/packages/nx/bin/init-local.ts @@ -14,6 +14,12 @@ export async function initLocal(workspace: WorkspaceTypeAndRoot) { process.env.NX_CLI_SET = 'true'; try { + // In case Nx Cloud forcibly exits while the TUI is running, ensure the terminal is restored etc. + process.on('exit', (...args) => { + if (typeof globalThis.tuiOnProcessExit === 'function') { + globalThis.tuiOnProcessExit(...args); + } + }); performance.mark('init-local'); if (workspace.type !== 'nx' && shouldDelegateToAngularCLI()) { diff --git a/packages/nx/bin/nx.ts b/packages/nx/bin/nx.ts index c9cc6e5ec5..d2fe60eee6 100644 --- a/packages/nx/bin/nx.ts +++ b/packages/nx/bin/nx.ts @@ -22,13 +22,6 @@ import { setupWorkspaceContext } from '../src/utils/workspace-context'; import { daemonClient } from '../src/daemon/client/client'; import { removeDbConnections } from '../src/utils/db-connection'; -// In case Nx Cloud forcibly exits while the TUI is running, ensure the terminal is restored etc. -process.on('exit', (...args) => { - if (typeof globalThis.tuiOnProcessExit === 'function') { - globalThis.tuiOnProcessExit(...args); - } -}); - async function main() { if ( process.argv[2] !== 'report' &&