From 5d968bd2939f51119a0117ab43e5266fb5dbcaa1 Mon Sep 17 00:00:00 2001 From: Marcel Kloubert Date: Thu, 5 Oct 2017 06:28:37 +0200 Subject: [PATCH] added placeholder support for 'dir' property of SFTP targets --- CHANGELOG.md | 4 ++++ package-lock.json | 2 +- package.json | 2 +- src/plugins/sftp.ts | 26 ++++++++++++-------------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e30bd19..6b5b144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log (vs-deploy) +## 9.33.0 (October 5th, 2017; placeholders in SFTP targets) + +* `dir` property of [sftp targets](https://github.com/mkloubert/vs-deploy/wiki/target_sftp) now supports [placeholders](https://github.com/mkloubert/vs-deploy/wiki/values) + ## 9.32.6 (October 4th, 2017; brazilian portuguese translation) * [portuguese (brazilian) translation](https://github.com/mkloubert/vs-deploy/blob/master/src/lang/pt-br.ts) updated by [Celio Rodrigues](https://github.com/rodriguescelio) diff --git a/package-lock.json b/package-lock.json index be2807c..ef111e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vs-deploy", - "version": "9.32.6", + "version": "9.33.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ba58faf..f45639e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vs-deploy", "displayName": "Deploy", "description": "Commands for deploying files of your workspace to a destination.", - "version": "9.32.6", + "version": "9.33.0", "publisher": "mkloubert", "engines": { "vscode": "^1.6.0" diff --git a/src/plugins/sftp.ts b/src/plugins/sftp.ts index a9f4575..a3ce8ea 100644 --- a/src/plugins/sftp.ts +++ b/src/plugins/sftp.ts @@ -101,15 +101,6 @@ type SSHCommands = SSHCommandEntry | SSHCommandEntry[]; const MODE_PAD = '000'; const TOUCH_TIME_FORMAT = 'YYYYMMDDHHmm.ss'; -function getDirFromTarget(target: DeployTargetSFTP): string { - let dir = deploy_helpers.toStringSafe(target.dir); - if ('' === dir) { - dir = '/'; - } - - return dir; -} - function toHashSafe(hash: string): string { return deploy_helpers.normalizeString(hash); } @@ -468,8 +459,6 @@ class SFtpPlugin extends deploy_objects.DeployPluginWithContextBase let host = deploy_helpers.toStringSafe(target.host, deploy_contracts.DEFAULT_HOST); let port = parseInt(deploy_helpers.toStringSafe(target.port, '22').trim()); - - // username and password let user = deploy_helpers.toStringSafe(target.user); if ('' === user) { @@ -706,7 +695,7 @@ class SFtpPlugin extends deploy_objects.DeployPluginWithContextBase return; } - let dir = getDirFromTarget(target); + let dir = me.getDirFromTarget(target); let targetFile = toSFTPPath(Path.join(dir, relativeFilePath)); let targetDirectory = toSFTPPath(Path.dirname(targetFile)); @@ -1066,7 +1055,7 @@ class SFtpPlugin extends deploy_objects.DeployPluginWithContextBase return; } - let dir = getDirFromTarget(target); + let dir = me.getDirFromTarget(target); let targetFile = toSFTPPath(Path.join(dir, relativeFilePath)); let targetDirectory = toSFTPPath(Path.dirname(targetFile)); @@ -1176,6 +1165,15 @@ class SFtpPlugin extends deploy_objects.DeployPluginWithContextBase }); } + protected getDirFromTarget(target: DeployTargetSFTP): string { + let dir = this.context.replaceWithValues(target.dir); + if (deploy_helpers.isEmptyString(dir)) { + dir = '/'; + } + + return dir; + } + protected async getFileInfoWithContext(ctx: SFTPContext, file: string, target: DeployTargetSFTP, opts: deploy_contracts.DeployFileOptions): Promise { let me = this; @@ -1185,7 +1183,7 @@ class SFtpPlugin extends deploy_objects.DeployPluginWithContextBase throw new Error(i18.t('relativePaths.couldNotResolve', file)); } - let dir = getDirFromTarget(target); + let dir = me.getDirFromTarget(target); let targetFile = toSFTPPath(Path.join(dir, relativeFilePath)); let targetDirectory = toSFTPPath(Path.dirname(targetFile));