From 687d79634af3bc3ca7676addf50ef3dc21193b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=C3=A1rio?= Date: Fri, 12 May 2023 11:50:06 +0000 Subject: [PATCH 1/2] Support for sftp server path to be selected by client --- lib/client.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/client.js b/lib/client.js index 3e393e50..1a66ce7a 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1554,7 +1554,7 @@ class Client extends EventEmitter { return this; } - sftp(cb) { + sftp(cb, { command } = {}) { if (!this._sock || !isWritable(this._sock)) throw new Error('Not connected'); @@ -1564,7 +1564,7 @@ class Client extends EventEmitter { return; } - reqSubsystem(sftp, 'sftp', (err, sftp_) => { + const sftpCb = (err, sftp_) => { if (err) { cb(err); return; @@ -1605,12 +1605,18 @@ class Client extends EventEmitter { } sftp.on('ready', onReady) - .on('error', onError) + .on('error', onError) .on('exit', onExit) .on('close', onExit); sftp._init(); - }); + }; + + if (command) { + reqExec(sftp, command, {}, sftpCb); + } else { + reqSubsystem(sftp, 'sftp', sftpCb); + } }); return this; From ed192477cb8235e057f152d275ad34579ed20937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=C3=A1rio?= Date: Fri, 12 May 2023 11:52:04 +0000 Subject: [PATCH 2/2] Fix indent --- lib/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index 1a66ce7a..0c880c82 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1605,7 +1605,7 @@ class Client extends EventEmitter { } sftp.on('ready', onReady) - .on('error', onError) + .on('error', onError) .on('exit', onExit) .on('close', onExit);