smartdeno/ts/classes.smartdeno.ts
2024-03-17 21:24:25 +01:00

34 lines
993 B
TypeScript

import { DenoDownloader } from './classes.denodownloader.js';
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import { ScriptServer } from './classes.scriptserver.js';
import { DenoExecution } from './classes.denoexecution.js';
export class SmartDeno {
private denoDownloader = new DenoDownloader();
private scriptServer = new ScriptServer();
public async start(optionsArg: {
forceLocalDeno?: boolean;
} = {}) {
const denoAlreadyInPath = await plugins.smarthshell.which('deno', {
nothrow: true
});
if (!denoAlreadyInPath || optionsArg.forceLocalDeno) {
await this.denoDownloader.download(plugins.path.join(paths.nogitDir, 'deno.zip'));
}
await this.scriptServer.start();
}
/**
* Stops the smartdeno instance
*/
public async stop() {
}
public async executeScript(scriptArg: string) {
const denoExecution = new DenoExecution(this.scriptServer, scriptArg);
await denoExecution.execute();
}
}