Skip to content

Commit

Permalink
[CopyFilesOverSSH] Addressed code review points
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Dobrodeev committed Jul 21, 2020
1 parent b9a6cfd commit 9298ae8
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Tasks/CopyFilesOverSSHV0/copyfilesoverssh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ async function run() {
let targetPath = path.posix.join(targetFolder, relativePath);

if (!path.isAbsolute(targetPath)) {
targetPath = './' + targetPath
targetPath = `./${targetPath}`;
}

console.log(tl.loc('StartedFileCopy', fileToCopy, targetPath));
Expand Down
181 changes: 77 additions & 104 deletions Tasks/CopyFilesOverSSHV0/package-lock.json

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

13 changes: 9 additions & 4 deletions Tasks/CopyFilesOverSSHV0/sshhelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export class SshHelper {
await defer.promise;
}

private unixyPath(filepath) {
if (process.platform === 'win32') {
return filepath.replace(/\\/g, '/');
}
return filepath;
}

/**
* Sets up the SSH connection
*/
Expand Down Expand Up @@ -98,9 +105,7 @@ export class SshHelper {
* @returns {Promise<string>}
*/
async uploadFile(sourceFile: string, dest: string) : Promise<string> {
if (process.platform === 'win32') {
dest = dest.replace(/\\/g, '/');
}
dest = this.unixyPath(dest);

tl.debug('Upload ' + sourceFile + ' to ' + dest + ' on remote machine.');

Expand Down Expand Up @@ -142,7 +147,7 @@ export class SshHelper {
if(!this.sftpClient) {
defer.reject(tl.loc('ConnectionNotSetup'));
}
if (await this.sftpClient.stat(path)) {
if (await this.sftpClient.exsts(path)) {
//path exists
defer.resolve(true);
} else {
Expand Down

0 comments on commit 9298ae8

Please sign in to comment.