Skip to content

Commit

Permalink
Merge pull request #475 from kimbob13/no_trim_cmd_exec
Browse files Browse the repository at this point in the history
Remove trim on result of exec command
  • Loading branch information
steelbrain authored Apr 18, 2024
2 parents 6c57d8f + cf01d4c commit c4bc27f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface SSHExecCommandOptions {
stdin?: string | stream.Readable
execOptions?: ExecOptions
encoding?: BufferEncoding
noTrim?: boolean
onChannel?: (clientChannel: ClientChannel) => void
onStdout?: (chunk: Buffer) => void
onStderr?: (chunk: Buffer) => void
Expand Down Expand Up @@ -417,11 +418,18 @@ export class NodeSSH {
signal = signal_ ?? null
})
channel.on('close', () => {
let stdout = output.stdout.join('')
let stderr = output.stderr.join('')
if (options.noTrim !== true) {
stdout = stdout.trim()
stderr = stderr.trim()
}

resolve({
code: code != null ? code : null,
signal: signal != null ? signal : null,
stdout: output.stdout.join('').trim(),
stderr: output.stderr.join('').trim(),
stdout: stdout,
stderr: stderr,
})
})
})
Expand Down

0 comments on commit c4bc27f

Please sign in to comment.