Files
bare-operating-system/packages/bare-os-booter/test.bare-openssh-pty.js
T
Raven Scott 2b9a10e371 Normalize embedded newlines to CRLF in SSH child ctx console log/error so
multiline output (e.g. man, bare-slice pager) matches real PTY behavior and
avoids misaligned lines vs the peer terminal.

Mirror pty-req TERM and dimensions into forked session vfs.env (COLUMNS,
LINES) when bareOsForkShellEnv is used; clear target on session end.

Add bare-openssh-pty-console helper module and brittle tests; re-export
formatter from bare-openssh for API parity.
2026-04-09 00:53:45 -04:00

23 lines
951 B
JavaScript

import test from 'brittle'
import { bareOpensshFormatConsoleTextForPty } from './lib/bare-openssh-pty-console.js'
test('bareOpensshFormatConsoleTextForPty converts LF to CRLF', (t) => {
t.is(bareOpensshFormatConsoleTextForPty('a\nb'), 'a\r\nb')
t.is(bareOpensshFormatConsoleTextForPty('a\n\nb'), 'a\r\n\r\nb')
})
test('bareOpensshFormatConsoleTextForPty leaves CRLF unchanged', (t) => {
t.is(bareOpensshFormatConsoleTextForPty('a\r\nb'), 'a\r\nb')
})
test('bareOpensshFormatConsoleTextForPty matches ssh console.log line wrapping', (t) => {
function sshPtyConsolePayload(...args) {
const body = args.map(String).join(' ')
const normalized = bareOpensshFormatConsoleTextForPty(body)
return normalized.endsWith('\r\n') ? normalized : normalized + '\r\n'
}
t.is(sshPtyConsolePayload('x'), 'x\r\n')
t.is(sshPtyConsolePayload('line1\nline2'), 'line1\r\nline2\r\n')
t.is(sshPtyConsolePayload('already\r\n'), 'already\r\n')
})