smartshell/ts/classes.smartexecution.ts

24 lines
702 B
TypeScript
Raw Permalink Normal View History

import * as plugins from './plugins.js'
import { Smartshell, type IExecResultStreaming } from './classes.smartshell.js';
export class SmartExecution {
public smartshell: Smartshell;
public currentStreamingExecution: IExecResultStreaming;
public commandString: string;
constructor(commandStringArg: string) {
this.commandString = commandStringArg;
}
public async restart() {
if (!this.smartshell) {
this.smartshell = new Smartshell({
executor: 'bash',
});
}
if (this.currentStreamingExecution) {
await this.currentStreamingExecution.kill();
}
this.currentStreamingExecution = await this.smartshell.execStreaming(this.commandString);
}
}