Skip to content

Commit

Permalink
fix open in shell command (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
ABevier authored May 6, 2023
1 parent f0e1af6 commit 508462e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
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

0 comments on commit 508462e

Please sign in to comment.