smartssh/ts/smartssh.classes.sshdir.ts

31 lines
1.1 KiB
TypeScript
Raw Normal View History

2016-05-31 17:00:52 +00:00
import "typings-global";
import * as plugins from "./smartssh.plugins";
import * as helpers from "./smartssh.classes.helpers";
2016-06-01 00:31:29 +00:00
import {SshInstance} from "./smartssh.classes.sshinstance";
import {SshKey} from "./smartssh.classes.sshkey";
import {SshConfig} from "./smartssh.classes.sshconfig";
export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
2016-05-31 22:56:24 +00:00
path:string; // the path of the ssh directory
2016-06-24 18:58:55 +00:00
private sshKeyArray:SshKey[];
2016-06-25 13:30:57 +00:00
private sshConfig:SshConfig;
constructor(sshKeyArray:SshKey[],sshConfig:SshConfig,sshDirPathArg?:string){
2016-06-24 18:58:55 +00:00
this.sshKeyArray = sshKeyArray;
2016-05-31 22:56:24 +00:00
if(sshDirPathArg){
2016-06-24 18:58:55 +00:00
this.path = sshDirPathArg;
2016-05-31 22:56:24 +00:00
} else {
2016-06-24 18:58:55 +00:00
this.path = plugins.path.join(plugins.smartpath.get.home(),".ssh/");
};
2016-05-31 17:00:52 +00:00
}
2016-06-24 00:49:55 +00:00
writeToDir(){ // syncs sshInstance to directory
2016-06-24 18:58:55 +00:00
this.sshKeyArray.forEach((sshKeyArg) => {
sshKeyArg.store(this.path);
});
2016-06-25 13:30:57 +00:00
this.sshConfig.store(this.path);
2016-05-31 17:00:52 +00:00
};
2016-06-24 00:49:55 +00:00
readFromDir(){ // syncs sshInstance from directory
2016-06-01 00:31:29 +00:00
}
2016-05-31 17:00:52 +00:00
getKeys(){
return helpers.sshKeyArrayFromDir(this.path);
}
}