Skip to content

Commit fca27fa

Browse files
authored
Merge pull request #485 from Yurii201811/codex/preserve-execcommand-output
Document execCommand noTrim output preservation
2 parents c87c768 + ae9e5da commit fca27fa

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ ssh.connect({
8484
console.log('STDOUT: ' + result.stdout)
8585
console.log('STDERR: ' + result.stderr)
8686
})
87+
// Command output is trimmed by default. Pass noTrim when leading or trailing
88+
// whitespace is meaningful, such as reading exact file contents.
89+
ssh.execCommand('git show --textconv HEAD:README.md', { noTrim: true }).then(function(result) {
90+
console.log('STDOUT: ' + result.stdout)
91+
})
8792
// Command with escaped params
8893
ssh.exec('hh_client', ['--json'], { cwd: '/var/www', stream: 'stdout', options: { pty: true } }).then(function(result) {
8994
console.log('STDOUT: ' + result)

test/main-test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,4 +501,11 @@ sshit('has a working noTrim option', async function (t, port, client) {
501501

502502
const resultWithoutTrim = await client.exec('echo', ['\n\n\nhi\n\n\n'], {stream: 'stdout', noTrim: true})
503503
t.is(resultWithoutTrim, '\n\n\nhi\n\n\n\n')
504+
505+
const commandResult = await client.execCommand(
506+
'node -e "process.stdout.write(\'\\nstdout\\n\\n\'); process.stderr.write(\'\\nstderr\\n\\n\')"',
507+
{ noTrim: true },
508+
)
509+
t.is(commandResult.stdout, '\nstdout\n\n')
510+
t.is(commandResult.stderr, '\nstderr\n\n')
504511
})

0 commit comments

Comments
 (0)