Skip to content

Commit c4bc27f

Browse files
authored
Merge pull request #475 from kimbob13/no_trim_cmd_exec
Remove trim on result of exec command
2 parents 6c57d8f + cf01d4c commit c4bc27f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/index.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface SSHExecCommandOptions {
4343
stdin?: string | stream.Readable
4444
execOptions?: ExecOptions
4545
encoding?: BufferEncoding
46+
noTrim?: boolean
4647
onChannel?: (clientChannel: ClientChannel) => void
4748
onStdout?: (chunk: Buffer) => void
4849
onStderr?: (chunk: Buffer) => void
@@ -417,11 +418,18 @@ export class NodeSSH {
417418
signal = signal_ ?? null
418419
})
419420
channel.on('close', () => {
421+
let stdout = output.stdout.join('')
422+
let stderr = output.stderr.join('')
423+
if (options.noTrim !== true) {
424+
stdout = stdout.trim()
425+
stderr = stderr.trim()
426+
}
427+
420428
resolve({
421429
code: code != null ? code : null,
422430
signal: signal != null ? signal : null,
423-
stdout: output.stdout.join('').trim(),
424-
stderr: output.stderr.join('').trim(),
431+
stdout: stdout,
432+
stderr: stderr,
425433
})
426434
})
427435
})

0 commit comments

Comments
 (0)