Skip to content

Commit a804652

Browse files
Merge pull request #3 from Jhonsensf/master
feat: add port option
2 parents f31b78a + 132489e commit a804652

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ Requires sshpass tool to be installed in the SO.
2121
}
2222
```
2323

24+
By default, the executor use the port 22, it is possible to indicate a different port with the property ```"remotePort"```
25+
2426
It is possible to use ```"remotePassword"``` instead off ```"identityFile"```
2527

2628

29+
2730
[Runnerty]: http://www.runnerty.io

index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ class scpExecutor extends Execution {
1313
var _this = this;
1414
var endOptions = {};
1515

16-
if (params.remotePassword){
17-
var scpCommand = `sshpass -p ${params.remotePassword} scp ${params.localFile} ${params.remoteUser}@${params.remoteHost}:${params.remoteFilePath}`;
18-
}else{
19-
var scpCommand = `scp ${(params.identityFile) ? "-i" : ""} ${params.identityFile} ${params.localFile} ${params.remoteUser}@${params.remoteHost}:${params.remoteFilePath}`;
20-
}
16+
let port = (params.remotePort) ? `-P ${params.remotePort}`'-P 22';
17+
let password = (params.remotePassword)?`sshpass -p ${params.remotePassword}`:"";
18+
let identityFile = (params.identityFile && password === "") ? `-i ${params.identityFile}` : "";
19+
20+
var scpCommand = `${password} scp ${port} ${identityFile} ${params.localFile} ${params.remoteUser}@${params.remoteHost}:${params.remoteFilePath}`;
21+
2122
endOptions.command_executed = scpCommand;
2223
var proc = spawn(scpCommand, [], {shell: true});
2324

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@runnerty/executor-scp",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Runnerty module: scp executor",
55
"author": "Coderty",
66
"license": "MIT",

schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
},
2828
"remoteHost": {
2929
"type": "string"
30+
},
31+
"remotePort": {
32+
"type": "number"
3033
}
3134
}
3235
},
@@ -57,6 +60,9 @@
5760
},
5861
"remoteHost": {
5962
"type": "string"
63+
},
64+
"remotePort": {
65+
"type": "number"
6066
}
6167
}
6268
}

0 commit comments

Comments
 (0)