From 508462e9cc048baf577ed4376e607f78098b95e7 Mon Sep 17 00:00:00 2001 From: ABevier Date: Fri, 5 May 2023 22:59:32 -0400 Subject: [PATCH] fix open in shell command (#566) --- modules/desktop/electron/libs/cli.ts | 3 ++- modules/desktop/electron/libs/initialize.ts | 8 ++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/desktop/electron/libs/cli.ts b/modules/desktop/electron/libs/cli.ts index 34193d0..35b4ff3 100644 --- a/modules/desktop/electron/libs/cli.ts +++ b/modules/desktop/electron/libs/cli.ts @@ -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( @@ -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`; diff --git a/modules/desktop/electron/libs/initialize.ts b/modules/desktop/electron/libs/initialize.ts index d784403..560df6e 100644 --- a/modules/desktop/electron/libs/initialize.ts +++ b/modules/desktop/electron/libs/initialize.ts @@ -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"; @@ -13,13 +11,11 @@ type InitState = "NOT_INITIALIZED" | "PENDING" | "INITIALIZED"; class InitWatcher { private initState: InitState; private initFunction: () => Promise; - private initialValue: T | undefined; private initializationPromise: Promise | undefined; constructor(initFunction: () => Promise) { this.initState = "NOT_INITIALIZED"; this.initFunction = initFunction; - this.initialValue = undefined; this.initializationPromise = undefined; } @@ -28,7 +24,6 @@ class InitWatcher { this.initState = "PENDING"; this.initializationPromise = this.retryFunction(this.initFunction, 3) .then((value) => { - this.initialValue = value; this.initState = "INITIALIZED"; return value; }) @@ -69,6 +64,7 @@ class InitWatcher { } } +// 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(async () => {