Skip to content

Commit e1525c5

Browse files
committed
fix(cli): stop any active spinner before printing error output
1 parent edf7906 commit e1525c5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/cli/src/cli-entry.mts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
getSocketCliBootstrapSpec,
4343
} from '@socketsecurity/lib/env/socket-cli'
4444
import { getDefaultLogger } from '@socketsecurity/lib/logger'
45+
import { getDefaultSpinner } from '@socketsecurity/lib/spinner'
4546

4647
import { rootAliases, rootCommands } from './commands.mts'
4748
import { SOCKET_CLI_BIN_NAME } from './constants/packages.mts'
@@ -174,6 +175,12 @@ void (async () => {
174175
} catch (e) {
175176
process.exitCode = 1
176177

178+
// Stop any active spinner before emitting error output, otherwise
179+
// its animation clashes with the error text on the same line.
180+
// Spinner-wrapped command paths stop their own on catch, but any
181+
// exception that bypasses those handlers reaches us here.
182+
getDefaultSpinner()?.stop()
183+
177184
// Track CLI error for telemetry.
178185
await trackCliError(process.argv, cliStartTime, e, process.exitCode)
179186
debug('CLI uncaught error')
@@ -195,8 +202,6 @@ void (async () => {
195202
if (isJson) {
196203
logger.log(serializeResultJson(formatErrorForJson(e)))
197204
} else {
198-
// Add 2 newlines in stderr to bump below any spinner.
199-
logger.error('\n')
200205
logger.error(formatErrorForTerminal(e))
201206
debugDirNs('inspect', { error: e })
202207
}

0 commit comments

Comments
 (0)