fix(core): update

This commit is contained in:
2024-01-24 00:59:11 +01:00
parent 321ce99338
commit c021a84788
3 changed files with 25 additions and 7 deletions

View File

@@ -27,6 +27,9 @@ export class DeesTerminal extends DeesElement {
// INSTANCE
private resizeObserver: ResizeObserver;
@property()
public setupCommand = `pnpm install @git.zone/tsbuild && clear && echo 'welcome'`;
constructor() {
super();
this.resizeObserver = new ResizeObserver((entries) => {
@@ -278,8 +281,9 @@ export class DeesTerminal extends DeesElement {
term.onData((data) => {
input.write(data);
});
await domtools.convenience.smartdelay.delayFor(5000);
input.write(`pnpm add isomorphic-git @git.zone/tsbuild\n`);
await this.waitForPrompt(term, '~/');
input.write(this.setupCommand);
input.write(`\n`);
}
async connectedCallback(): Promise<void> {
@@ -295,4 +299,22 @@ export class DeesTerminal extends DeesElement {
handleResize() {
this.fitAddon.fit();
}
private async waitForPrompt(term: Terminal, prompt: string): Promise<void> {
return new Promise<void>((resolve) => {
const checkPrompt = () => {
const lines = term.buffer.active;
for (let i = 0; i < lines.length; i++) {
const line = lines.getLine(i);
if (line && line.translateToString().includes(prompt)) {
resolve();
return;
}
}
setTimeout(checkPrompt, 100); // check every 100 ms
};
checkPrompt();
});
}
}