From a1ecb6a3b693d997377f6cdbe16717c0a5dd418b Mon Sep 17 00:00:00 2001 From: tmas Date: Mon, 9 Nov 2020 14:51:08 -0500 Subject: [PATCH] Allow agent config to use environment variables Resolves #281 --- modules/ftp-config.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/ftp-config.js b/modules/ftp-config.js index 1d250ff..dfa06e6 100644 --- a/modules/ftp-config.js +++ b/modules/ftp-config.js @@ -88,12 +88,23 @@ module.exports = { protocol: config.protocol || "ftp", privateKeyPath: config.privateKeyPath, passphrase: config.passphrase, - agent: config.agent, + agent: this.resolveConfigValue(config.agent), generatedFiles: config.generatedFiles, debug: config.debug, rootPath: this.rootPath }; }, + resolveConfigValue: function(value) { + if (typeof value !== 'string') { + return value; + } + if (value.charAt(0) === '$') { + // resolve as an environment variable + let envVar = value.substr(1); + return process.env[envVar]; + } + return value; + }, connectionChanged: function(oldConfig) { var config = this.getSyncConfig(); return (