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

Commit 986aec1

Browse files
authored
fix: fix remote command wont reject on error, when cwd option is used (#265)
1 parent 3b62c22 commit 986aec1

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

packages/ssh-pool/src/Connection.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('Connection', () => {
4949
await connection.run('my-command -x', { cwd: '/root' })
5050

5151
expect(exec).toHaveBeenCalledWith(
52-
'ssh user@host "cd /root > /dev/null; my-command -x; cd - > /dev/null"',
52+
'ssh user@host "cd /root > /dev/null && my-command -x; cd - > /dev/null"',
5353
{
5454
maxBuffer: 1024000,
5555
},

packages/ssh-pool/src/ConnectionPool.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ describe('ConnectionPool', () => {
5252
expect(results[0].stdout.toString()).toBe('stdout')
5353
expect(results[1].stdout.toString()).toBe('stdout')
5454
expect(exec).toHaveBeenCalledWith(
55-
'ssh deploy@myserver2 "cd /root > /dev/null; my-command -x; cd - > /dev/null"',
55+
'ssh deploy@myserver2 "cd /root > /dev/null && my-command -x; cd - > /dev/null"',
5656
{
5757
maxBuffer: 1000 * 1024,
5858
},
5959
expect.any(Function),
6060
)
6161
expect(exec).toHaveBeenCalledWith(
62-
'ssh deploy@myserver "cd /root > /dev/null; my-command -x; cd - > /dev/null"',
62+
'ssh deploy@myserver "cd /root > /dev/null && my-command -x; cd - > /dev/null"',
6363
{
6464
maxBuffer: 1000 * 1024,
6565
},

packages/ssh-pool/src/commands/ssh.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { joinCommandArgs, wrapCommand } from './util'
22

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

77
export function formatSshCommand({

packages/ssh-pool/src/commands/ssh.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('ssh', () => {
6060
cwd: '/usr',
6161
}),
6262
).toBe(
63-
'ssh user@host "cd /usr > /dev/null; echo \\"ok\\"; cd - > /dev/null"',
63+
'ssh user@host "cd /usr > /dev/null && echo \\"ok\\"; cd - > /dev/null"',
6464
)
6565
})
6666

@@ -73,7 +73,7 @@ describe('ssh', () => {
7373
verbosityLevel: 2,
7474
}),
7575
).toBe(
76-
'ssh -vv user@host "cd /usr > /dev/null; echo \\"ok\\"; cd - > /dev/null"',
76+
'ssh -vv user@host "cd /usr > /dev/null && echo \\"ok\\"; cd - > /dev/null"',
7777
)
7878
})
7979
})

0 commit comments

Comments
 (0)