diff --git a/packages/ssh-pool/src/Connection.test.js b/packages/ssh-pool/src/Connection.test.js index 86045bb..c906a21 100644 --- a/packages/ssh-pool/src/Connection.test.js +++ b/packages/ssh-pool/src/Connection.test.js @@ -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, }, diff --git a/packages/ssh-pool/src/ConnectionPool.test.js b/packages/ssh-pool/src/ConnectionPool.test.js index 963da0f..3c4a5c7 100644 --- a/packages/ssh-pool/src/ConnectionPool.test.js +++ b/packages/ssh-pool/src/ConnectionPool.test.js @@ -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, }, diff --git a/packages/ssh-pool/src/commands/ssh.js b/packages/ssh-pool/src/commands/ssh.js index 2bd1dce..21b48a2 100644 --- a/packages/ssh-pool/src/commands/ssh.js +++ b/packages/ssh-pool/src/commands/ssh.js @@ -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({ diff --git a/packages/ssh-pool/src/commands/ssh.test.js b/packages/ssh-pool/src/commands/ssh.test.js index eb39d63..3fb2bdc 100644 --- a/packages/ssh-pool/src/commands/ssh.test.js +++ b/packages/ssh-pool/src/commands/ssh.test.js @@ -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"', ) }) @@ -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"', ) }) })