Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion sdk/src/__tests__/run-terminal-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,21 @@ describe('rewriteWindowsNulRedirects', () => {
})

describe('BoundedOutputBuffer', () => {
test('preserves output below the limit and strips terminal colors', () => {
test('preserves output below the limit and strips terminal escape sequences', () => {
const output = new BoundedOutputBuffer(100)
output.append('\u001b[31')
output.append('mhello\u001b[0m world')

expect(output.format()).toBe('hello world')
})

test('strips cursor-control sequences', () => {
const output = new BoundedOutputBuffer(100)
output.append('before\u001b[2J\u001b[Hafter')

expect(output.format()).toBe('beforeafter')
})

test('keeps a bounded prefix and suffix for oversized output', () => {
const output = new BoundedOutputBuffer(100)
output.append('start-' + 'x'.repeat(200) + '-end')
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/tools/run-terminal-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
} from 'child_process'
import type { Readable } from 'stream'

import { stripColors } from '../../../common/src/util/string'
import { stripAnsi } from '../../../common/src/util/string'
import { getSystemProcessEnv } from '../env'
import {
createWindowsBashNotFoundError,
Expand Down Expand Up @@ -92,7 +92,7 @@ export class BoundedOutputBuffer {
this.pendingColorSequence = incompleteColorSequence
normalized = normalized.slice(0, -incompleteColorSequence.length)
}
normalized = stripColors(normalized)
normalized = stripAnsi(normalized)
if (!normalized) return

if (!this.truncated) {
Expand Down
Loading