From d95bbb64a21223721b35038e1ac6f0a15c9571ba Mon Sep 17 00:00:00 2001 From: Razvan Azamfirei Date: Mon, 8 May 2023 06:53:54 -0400 Subject: [PATCH] add logic to handle tea prefix (#570) --- modules/desktop/electron/libs/tea-dir.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/desktop/electron/libs/tea-dir.ts b/modules/desktop/electron/libs/tea-dir.ts index f27e0da..fbfcafa 100644 --- a/modules/desktop/electron/libs/tea-dir.ts +++ b/modules/desktop/electron/libs/tea-dir.ts @@ -7,6 +7,7 @@ import type { InstalledPackage } from "../../src/libs/types"; import { mkdirp } from "mkdirp"; import fetch from "node-fetch"; import { SemVer, isValidSemVer } from "@tea/libtea"; +import { execSync } from "child_process"; type Dir = { name: string; @@ -18,7 +19,16 @@ type ParsedVersion = { full_name: string; semVer: SemVer }; export const getTeaPath = () => { const homePath = app.getPath("home"); - const teaPath = path.join(homePath, "./.tea"); + let teaPath; + + try { + teaPath = execSync("tea --prefix", { encoding: "utf8" }).trim(); + log.info(teaPath); + } catch (error) { + log.info("Could not run tea --prefix. Using default path.", info); + teaPath = path.join(homePath, "./.tea"); + } + return teaPath; };