Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
added placeholder support for 'dir' property of SFTP targets
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Oct 5, 2017
1 parent 7492f41 commit 5d968bd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
26 changes: 12 additions & 14 deletions src/plugins/sftp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -468,8 +459,6 @@ class SFtpPlugin extends deploy_objects.DeployPluginWithContextBase<SFTPContext>
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) {
Expand Down Expand Up @@ -706,7 +695,7 @@ class SFtpPlugin extends deploy_objects.DeployPluginWithContextBase<SFTPContext>
return;
}

let dir = getDirFromTarget(target);
let dir = me.getDirFromTarget(target);

let targetFile = toSFTPPath(Path.join(dir, relativeFilePath));
let targetDirectory = toSFTPPath(Path.dirname(targetFile));
Expand Down Expand Up @@ -1066,7 +1055,7 @@ class SFtpPlugin extends deploy_objects.DeployPluginWithContextBase<SFTPContext>
return;
}

let dir = getDirFromTarget(target);
let dir = me.getDirFromTarget(target);

let targetFile = toSFTPPath(Path.join(dir, relativeFilePath));
let targetDirectory = toSFTPPath(Path.dirname(targetFile));
Expand Down Expand Up @@ -1176,6 +1165,15 @@ class SFtpPlugin extends deploy_objects.DeployPluginWithContextBase<SFTPContext>
});
}

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<deploy_contracts.FileInfo> {
let me = this;
Expand All @@ -1185,7 +1183,7 @@ class SFtpPlugin extends deploy_objects.DeployPluginWithContextBase<SFTPContext>
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));
Expand Down

0 comments on commit 5d968bd

Please sign in to comment.