feat: save files

This commit is contained in:
xiaojunnuo
2023-06-25 23:25:56 +08:00
parent 2851a33eb2
commit 671d273e2f
30 changed files with 253 additions and 222 deletions

View File

@@ -61,6 +61,9 @@ export class SshClient {
return new Promise((resolve, reject) => {
this.connect({
connectConf,
onError(err: any) {
reject(err);
},
onReady: (conn: any) => {
conn.exec(script, (err: Error, stream: any) => {
if (err) {
@@ -98,6 +101,10 @@ export class SshClient {
return new Promise((resolve, reject) => {
this.connect({
connectConf,
onError: (err: any) => {
this.logger.error(err);
reject(err);
},
onReady: (conn: any) => {
conn.shell((err: Error, stream: any) => {
if (err) {
@@ -122,10 +129,13 @@ export class SshClient {
});
}
connect(options: { connectConf: any; onReady: any }) {
const { connectConf, onReady } = options;
connect(options: { connectConf: any; onReady: any; onError: any }) {
const { connectConf, onReady, onError } = options;
const conn = new ssh2.Client();
conn
.on("error", (err: any) => {
onError(err);
})
.on("ready", () => {
this.logger.info("Client :: ready");
onReady(conn);