fix open in shell command (#566)

This commit is contained in:
ABevier 2023-05-05 22:59:32 -04:00 committed by GitHub
parent f0e1af6253
commit 508462e9cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 7 deletions

View file

@ -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`;

View file

@ -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<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;
}
@ -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;
})
@ -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 () => {