Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/desktop/electron/libs/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { app } from "electron";
import log from "./logger";
import { MainWindowNotifier } from "./types";

// Be careful with globbing when passing this to a shell which might expand it. Either escape it or quote it.
export const cliBinPath = path.join(getTeaPath(), "tea.xyz/v*/bin/tea");

export async function installPackage(
Expand Down Expand Up @@ -120,7 +121,7 @@ const notifyPackageInstalled = (rawPkg: string, notifyMainWindow: MainWindowNoti
};

export async function openPackageEntrypointInTerminal(pkg: string) {
let sh = `${cliBinPath} --sync --env=false +${pkg} `;
let sh = `"${cliBinPath}" --sync --env=false +${pkg} `;
switch (pkg) {
case "github.com/AUTOMATIC1111/stable-diffusion-webui":
sh += `~/.tea/${pkg}/v*/entrypoint.sh`;
Expand Down
8 changes: 2 additions & 6 deletions modules/desktop/electron/libs/initialize.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import fs from "fs";
import { getGuiPath, getTeaPath } from "./tea-dir";
import log from "./logger";
// import { cliBinPath, asyncExec } from "./cli";
import { getTeaPath } from "./tea-dir";
import { createInitialSessionFile } from "./auth";
import * as https from "https";
import { spawn } from "child_process";
Expand All @@ -13,13 +11,11 @@ type InitState = "NOT_INITIALIZED" | "PENDING" | "INITIALIZED";
class InitWatcher<T> {
private initState: InitState;
private initFunction: () => Promise<T>;
private initialValue: T | undefined;
private initializationPromise: Promise<T> | undefined;

constructor(initFunction: () => Promise<T>) {
this.initState = "NOT_INITIALIZED";
this.initFunction = initFunction;
this.initialValue = undefined;
this.initializationPromise = undefined;
}

Expand All @@ -28,7 +24,6 @@ class InitWatcher<T> {
this.initState = "PENDING";
this.initializationPromise = this.retryFunction(this.initFunction, 3)
.then((value) => {
this.initialValue = value;
this.initState = "INITIALIZED";
return value;
})
Expand Down Expand Up @@ -69,6 +64,7 @@ class InitWatcher<T> {
}
}

// Be careful with globbing when passing this to a shell which might expand it. Either escape it or quote it.
const teaCliPrefix = path.join(getTeaPath(), "tea.xyz/v*");

export const cliInitializationState = new InitWatcher<string>(async () => {
Expand Down