Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
fix: fix remote command wont reject on error, when cwd option is used (
Browse files Browse the repository at this point in the history
  • Loading branch information
jfilla authored Mar 7, 2020
1 parent 3b62c22 commit 986aec1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/ssh-pool/src/Connection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Connection', () => {
await connection.run('my-command -x', { cwd: '/root' })

expect(exec).toHaveBeenCalledWith(
'ssh user@host "cd /root > /dev/null; my-command -x; cd - > /dev/null"',
'ssh user@host "cd /root > /dev/null && my-command -x; cd - > /dev/null"',
{
maxBuffer: 1024000,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/ssh-pool/src/ConnectionPool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ describe('ConnectionPool', () => {
expect(results[0].stdout.toString()).toBe('stdout')
expect(results[1].stdout.toString()).toBe('stdout')
expect(exec).toHaveBeenCalledWith(
'ssh deploy@myserver2 "cd /root > /dev/null; my-command -x; cd - > /dev/null"',
'ssh deploy@myserver2 "cd /root > /dev/null && my-command -x; cd - > /dev/null"',
{
maxBuffer: 1000 * 1024,
},
expect.any(Function),
)
expect(exec).toHaveBeenCalledWith(
'ssh deploy@myserver "cd /root > /dev/null; my-command -x; cd - > /dev/null"',
'ssh deploy@myserver "cd /root > /dev/null && my-command -x; cd - > /dev/null"',
{
maxBuffer: 1000 * 1024,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ssh-pool/src/commands/ssh.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { joinCommandArgs, wrapCommand } from './util'

function wrapCwd(cwd, command) {
return `cd ${cwd} > /dev/null; ${command}; cd - > /dev/null`
return `cd ${cwd} > /dev/null && ${command}; cd - > /dev/null`
}

export function formatSshCommand({
Expand Down
4 changes: 2 additions & 2 deletions packages/ssh-pool/src/commands/ssh.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('ssh', () => {
cwd: '/usr',
}),
).toBe(
'ssh user@host "cd /usr > /dev/null; echo \\"ok\\"; cd - > /dev/null"',
'ssh user@host "cd /usr > /dev/null && echo \\"ok\\"; cd - > /dev/null"',
)
})

Expand All @@ -73,7 +73,7 @@ describe('ssh', () => {
verbosityLevel: 2,
}),
).toBe(
'ssh -vv user@host "cd /usr > /dev/null; echo \\"ok\\"; cd - > /dev/null"',
'ssh -vv user@host "cd /usr > /dev/null && echo \\"ok\\"; cd - > /dev/null"',
)
})
})
Expand Down

0 comments on commit 986aec1

Please sign in to comment.