Skip to content

Commit 3cec915

Browse files
committed
refactor(deps): remove strip-ansi dependency, use Bun.stripANSI
Remove strip-ansi from dependencies as Bun provides stripANSI natively. Update E2E tests to use Bun.stripANSI instead of custom bunStripANSI function. Fix minor formatting issue in package.json. Reduces bundle size and simplifies code by leveraging Bun's built-in functionality.
1 parent d9d5c29 commit 3cec915

6 files changed

Lines changed: 12 additions & 38 deletions

bun.lock

Lines changed: 5 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
"@opencode-ai/sdk": "1.1.47",
9090
"bun-pty": "^0.4.8",
9191
"moment": "^2.30.1",
92-
"open": "^11.0.0",
93-
"strip-ansi": "^7.1.2"
92+
"open": "^11.0.0"
9493
}
95-
}
94+
}

test/e2e/extraction-methods-echo-prompt-match.pw.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
bunStripANSI,
32
getTerminalPlainText,
43
getSerializedContentByXtermSerializeAddon,
54
waitForTerminalRegex,
@@ -35,7 +34,7 @@ extendedTest(
3534

3635
// PRIMARY: SerializeAddon (robust extraction)
3736
const serializeContent = await getSerializedContentByXtermSerializeAddon(page)
38-
const serializeStrippedContent = bunStripANSI(serializeContent).split('\n')
37+
const serializeStrippedContent = Bun.stripANSI(serializeContent).split('\n')
3938

4039
// API
4140
const plainData = await api.session.buffer.plain({ id: session.id })

test/e2e/newline-verification.pw.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { test as extendedTest, expect } from './fixtures'
22
import {
33
waitForTerminalRegex,
44
getSerializedContentByXtermSerializeAddon,
5-
bunStripANSI,
65
} from './xterm-test-helpers'
76

87
extendedTest.describe('Xterm Newline Handling', () => {
@@ -39,8 +38,8 @@ extendedTest.describe('Xterm Newline Handling', () => {
3938
})
4039

4140
// Use robust character counting
42-
const cleanBefore = bunStripANSI(beforeContent)
43-
const cleanAfter = bunStripANSI(afterContent)
41+
const cleanBefore = Bun.stripANSI(beforeContent)
42+
const cleanAfter = Bun.stripANSI(afterContent)
4443
const beforeCount = (cleanBefore.match(/a/g) || []).length
4544
const afterCount = (cleanAfter.match(/a/g) || []).length
4645
expect(afterCount - beforeCount).toBe(1)
@@ -77,7 +76,7 @@ extendedTest.describe('Xterm Newline Handling', () => {
7776
await waitForTerminalRegex(page, /Hello World/)
7877

7978
// Get final terminal buffer via SerializeAddon (canonical, robust method)
80-
const finalBuffer = bunStripANSI(
79+
const finalBuffer = Bun.stripANSI(
8180
await getSerializedContentByXtermSerializeAddon(page, {
8281
excludeModes: true,
8382
excludeAltBuffer: true,

test/e2e/visual-verification-dom-vs-serialize-vs-plain.pw.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
bunStripANSI,
32
getSerializedContentByXtermSerializeAddon,
43
waitForTerminalRegex,
54
} from './xterm-test-helpers'
@@ -29,7 +28,7 @@ extendedTest.describe(
2928
await waitForTerminalRegex(page, /More text/)
3029

3130
// Extraction methods
32-
const serializeStrippedContent = bunStripANSI(
31+
const serializeStrippedContent = Bun.stripANSI(
3332
await getSerializedContentByXtermSerializeAddon(page)
3433
).split('\n')
3534
const plainData = await api.session.buffer.plain({ id: session.id })

test/e2e/xterm-test-helpers.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { Page } from '@playwright/test'
22
import type { SerializeAddon } from '@xterm/addon-serialize'
3-
import stripAnsi from 'strip-ansi'
43

54
// Global module augmentation for E2E testing
65
declare global {
@@ -10,22 +9,6 @@ declare global {
109
}
1110
}
1211

13-
// Use Bun.stripANSI if available, otherwise fallback to npm strip-ansi
14-
let bunStripANSI: (str: string) => string
15-
try {
16-
if (typeof Bun !== 'undefined' && Bun.stripANSI) {
17-
bunStripANSI = Bun.stripANSI
18-
} else {
19-
// Note: dynamic import only relevant in Bun, for typing only in Node
20-
const bunModule = await import('bun')
21-
bunStripANSI = bunModule.stripANSI
22-
}
23-
} catch {
24-
bunStripANSI = stripAnsi
25-
}
26-
27-
export { bunStripANSI }
28-
2912
/**
3013
* Deprecated: Use getSerializedContentByXtermSerializeAddon for all terminal content extraction in E2E tests.
3114
* This DOM scraping method should only be used for rare visual/manual cross-checks or debugging.

0 commit comments

Comments
 (0)