From c108790e193e4e1ff904d61668482642b8edabd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Val=C3=A9rio?= Date: Tue, 2 Mar 2021 22:23:27 -0300 Subject: [PATCH 1/2] Specify binary location Add an option to specify the lftp binary, the default is "lftp" --- index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 5388ec8..1afc89d 100644 --- a/index.js +++ b/index.js @@ -52,11 +52,12 @@ FTP.prototype.initialize = function (options) { cwd: '', // Use a different working directory additionalLftpCommands: '', // Additional commands to pass to lftp, splitted by ';' requireSSHKey: false, // This option for SFTP Protocol with ssh key authentication - sshKeyPath: '' // ssh key path for, SFTP Protocol with ssh key authentication + sshKeyPath: '', // ssh key path for, SFTP Protocol with ssh key authentication + bin: 'lftp', // specify lftp bin } // Extend options with defaults - var opts = _.pick(_.extend(defaults, options), 'host', 'username', 'password', 'port', 'escape', 'retries', 'timeout', 'retryInterval', 'retryIntervalMultiplier', 'requiresPassword', 'protocol', 'autoConfirm', 'cwd', 'additionalLftpCommands', 'requireSSHKey', 'sshKeyPath') + var opts = _.pick(_.extend(defaults, options), 'host', 'username', 'password', 'port', 'escape', 'retries', 'timeout', 'retryInterval', 'retryIntervalMultiplier', 'requiresPassword', 'protocol', 'autoConfirm', 'cwd', 'additionalLftpCommands', 'requireSSHKey', 'sshKeyPath', 'bin') // Validation if (!opts.host) throw new Error('You need to set a host.') @@ -72,6 +73,7 @@ FTP.prototype.initialize = function (options) { opts.host = opts.host + ':' + opts.port } this.options = opts + console.log(this.options) } FTP.prototype.escapeshell = function (cmd) { @@ -137,7 +139,7 @@ FTP.prototype.exec = function (cmds, callback) { } } - var lftp = spawn('lftp', ['-c', cmd], spawnoptions) + var lftp = spawn(this.options.bin, ['-c', cmd], spawnoptions) var data = '' var error = '' @@ -185,7 +187,7 @@ FTP.prototype.execAsStream = function (cmds) { } } - return dcp.spawn('lftp', ['-c', cmd], spawnoptions) + return dcp.spawn(this.options.bin, ['-c', cmd], spawnoptions) } FTP.prototype.raw = function (cmd) { From eda201f237d4dbee6dc8308138cd4c87628501eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Val=C3=A9rio?= Date: Tue, 2 Mar 2021 22:24:36 -0300 Subject: [PATCH 2/2] Remove console.log --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index 1afc89d..f071caf 100644 --- a/index.js +++ b/index.js @@ -73,7 +73,6 @@ FTP.prototype.initialize = function (options) { opts.host = opts.host + ':' + opts.port } this.options = opts - console.log(this.options) } FTP.prototype.escapeshell = function (cmd) {