smartdeno/ts/classes.smartdeno.ts

34 lines
993 B
TypeScript
Raw Normal View History

2024-03-16 23:53:32 +00:00
import { DenoDownloader } from './classes.denodownloader.js';
import * as plugins from './plugins.js';
import * as paths from './paths.js';
2024-03-17 20:24:25 +00:00
import { ScriptServer } from './classes.scriptserver.js';
import { DenoExecution } from './classes.denoexecution.js';
2024-03-16 23:53:32 +00:00
export class SmartDeno {
private denoDownloader = new DenoDownloader();
2024-03-17 20:24:25 +00:00
private scriptServer = new ScriptServer();
2024-03-16 23:53:32 +00:00
2024-03-17 20:24:25 +00:00
public async start(optionsArg: {
2024-03-16 23:53:32 +00:00
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'));
}
2024-03-17 20:24:25 +00:00
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();
2024-03-16 23:53:32 +00:00
}
}