This commit is contained in:
2026-08-18 18:11:28 -04:00
parent 0e9a650fa2
commit bbaf47028f
259 changed files with 0 additions and 0 deletions
@@ -0,0 +1,23 @@
/**
* SSH PTY console newline helpers (no bare-ssh2 import — safe for brittle-node tests).
*/
/**
* Normalize embedded newlines to CRLF for SSH PTY output (multiline `console.log`, e.g. `man`).
* @param {unknown} s
* @returns {string}
*/
export function bareOpensshFormatConsoleTextForPty(s) {
return String(s).replace(/\r?\n/g, '\r\n')
}
/**
* @param {import('stream').Duplex} stream
* @param {unknown[]} args
*/
export function bareOpensshWritePtyConsoleLine(stream, args) {
const body = args.map(String).join(' ')
const normalized = bareOpensshFormatConsoleTextForPty(body)
const out = normalized.endsWith('\r\n') ? normalized : normalized + '\r\n'
if (stream.writable) stream.write(out)
}