diff options
| author | Olcan <[email protected]> | 2025-06-02 14:50:12 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-02 14:50:12 -0700 |
| commit | 1dcf0a4cbdee249fd9a20c67b9b718563353773b (patch) | |
| tree | d858433eafd111282f4f3e3c730dcfe350cf7d37 /packages/cli/src/ui | |
| parent | 51949f3121dd924002974a4e50f5ee34fd14c3ef (diff) | |
strip ansi from shell output (#699)
Diffstat (limited to 'packages/cli/src/ui')
| -rw-r--r-- | packages/cli/src/ui/hooks/shellCommandProcessor.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/packages/cli/src/ui/hooks/shellCommandProcessor.ts b/packages/cli/src/ui/hooks/shellCommandProcessor.ts index 111df009..156b8eb6 100644 --- a/packages/cli/src/ui/hooks/shellCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/shellCommandProcessor.ts @@ -15,6 +15,7 @@ import crypto from 'crypto'; import path from 'path'; import os from 'os'; import fs from 'fs'; +import stripAnsi from 'strip-ansi'; const OUTPUT_UPDATE_INTERVAL_MS = 1000; @@ -126,12 +127,12 @@ export const useShellCommandProcessor = ( let exited = false; let output = ''; let lastUpdateTime = Date.now(); - const handleOutput = (data: string) => { + const handleOutput = (data: Buffer) => { // continue to consume post-exit for background processes // removing listeners can overflow OS buffer and block subprocesses // destroying (e.g. child.stdout.destroy()) can terminate subprocesses via SIGPIPE if (!exited) { - output += data; + output += stripAnsi(data.toString()); if (Date.now() - lastUpdateTime > OUTPUT_UPDATE_INTERVAL_MS) { setPendingHistoryItem({ type: 'info', |
