improve sync triggering
This commit is contained in:
parent
1d17dd1b84
commit
b73928109b
@ -3,8 +3,8 @@ import plugins = require("./smartssh.plugins");
|
|||||||
import helpers = require("./smartssh.classes.helpers");
|
import helpers = require("./smartssh.classes.helpers");
|
||||||
|
|
||||||
export class ssh {
|
export class ssh {
|
||||||
private sshConfig:sshConfig;
|
private sshConfig:sshConfig; // points to sshConfig class instance
|
||||||
private sshDir:sshDir;
|
private sshDir:sshDir; // points to sshDir class instance.
|
||||||
private sshKeys:sshKey[]; //holds all ssh keys
|
private sshKeys:sshKey[]; //holds all ssh keys
|
||||||
private sshSync:boolean; // if set to true, the ssh dir will be kept in sync automatically
|
private sshSync:boolean; // if set to true, the ssh dir will be kept in sync automatically
|
||||||
constructor(optionsArg:{sshDir?:string,sshSync?:boolean}={}){
|
constructor(optionsArg:{sshDir?:string,sshSync?:boolean}={}){
|
||||||
@ -29,13 +29,17 @@ export class ssh {
|
|||||||
removeKey(sshKeyArg:sshKey){
|
removeKey(sshKeyArg:sshKey){
|
||||||
let keyIndex = helpers.getKeyIndex(sshKeyArg.host);
|
let keyIndex = helpers.getKeyIndex(sshKeyArg.host);
|
||||||
this.sshKeys.splice(keyIndex,1);
|
this.sshKeys.splice(keyIndex,1);
|
||||||
|
this.sync();
|
||||||
};
|
};
|
||||||
replaceKey(sshKeyOldArg:sshKey,sshKeyNewArg:sshKey){
|
replaceKey(sshKeyOldArg:sshKey,sshKeyNewArg:sshKey){
|
||||||
let keyIndex = helpers.getKeyIndex(sshKeyOldArg.host);
|
let keyIndex = helpers.getKeyIndex(sshKeyOldArg.host);
|
||||||
this.sshKeys.splice(keyIndex,1,sshKeyNewArg);
|
this.sshKeys.splice(keyIndex,1,sshKeyNewArg);
|
||||||
|
this.sync();
|
||||||
};
|
};
|
||||||
sync(){
|
sync(){
|
||||||
|
if(this.sshSync){
|
||||||
this.sshDir.sync(this.sshConfig,this.sshKeys); // call sync method of sshDir class;
|
this.sshDir.sync(this.sshConfig,this.sshKeys); // call sync method of sshDir class;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user