From d7bc1d3aa9f45f36b45528efb819103d1fee6fa0 Mon Sep 17 00:00:00 2001 From: ABevier Date: Thu, 15 Jun 2023 19:43:46 -0400 Subject: [PATCH] get tea prefix from libtea instead of invoking the cli (#667) --- modules/desktop/electron/libs/tea-dir.ts | 15 +++++---------- modules/desktop/package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/desktop/electron/libs/tea-dir.ts b/modules/desktop/electron/libs/tea-dir.ts index a178031..ae62daa 100644 --- a/modules/desktop/electron/libs/tea-dir.ts +++ b/modules/desktop/electron/libs/tea-dir.ts @@ -6,25 +6,20 @@ import type { InstalledPackage } from "../../src/libs/types"; import { mkdirp } from "mkdirp"; import fetch from "node-fetch"; import { SemVer, semver } from "@teaxyz/lib"; -import { execSync } from "child_process"; import chokidar from "chokidar"; import { MainWindowNotifier } from "./types"; +import { hooks } from "@teaxyz/lib"; type ParsedVersion = { full_name: string; semVer: SemVer }; -export const getTeaPath = () => { - const homePath = app.getPath("home"); - let teaPath; - +export const getTeaPath = (): string => { try { - teaPath = execSync("tea --prefix", { encoding: "utf8" }).trim(); - log.info(teaPath); + return hooks.useConfig().prefix.toString(); } catch (error) { + const homePath = app.getPath("home"); log.info("Could not run tea --prefix. Using default path."); - teaPath = path.join(homePath, "./.tea"); + return path.join(homePath, "./.tea"); } - - return teaPath; }; const guiFolder = path.join(getTeaPath(), "tea.xyz/gui"); diff --git a/modules/desktop/package.json b/modules/desktop/package.json index a0f2b0c..cbaaee3 100644 --- a/modules/desktop/package.json +++ b/modules/desktop/package.json @@ -88,7 +88,7 @@ "@sentry/electron": "^4.4.0", "@sentry/svelte": "^7.47.0", "@sentry/vite-plugin": "^0.7.2", - "@teaxyz/lib": "0.4.1", + "@teaxyz/lib": "0.6.0", "@types/electron": "^1.6.10", "@types/mousetrap": "^1.6.11", "@vitest/coverage-c8": "^0.27.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 508dbea..b88d89a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,7 +27,7 @@ importers: '@sveltejs/adapter-static': ^1.0.0-next.48 '@sveltejs/kit': ^1.15.9 '@tea/ui': workspace:* - '@teaxyz/lib': 0.4.1 + '@teaxyz/lib': 0.6.0 '@testing-library/jest-dom': ^5.16.5 '@testing-library/svelte': ^3.2.2 '@testing-library/webdriverio': ^3.2.1 @@ -108,7 +108,7 @@ importers: '@sentry/electron': 4.5.0 '@sentry/svelte': 7.51.2_svelte@3.59.1 '@sentry/vite-plugin': 0.7.2 - '@teaxyz/lib': 0.4.1 + '@teaxyz/lib': 0.6.0 '@types/electron': 1.6.10 '@types/mousetrap': 1.6.11 '@vitest/coverage-c8': 0.27.3_jsdom@21.1.2 @@ -3628,8 +3628,8 @@ packages: tailwindcss: 3.3.2 dev: false - /@teaxyz/lib/0.4.1: - resolution: {integrity: sha512-DVXOFyhbS1fM5acBU4jdR6WybK6Rt15NaO7qqpkRx7TuNz5mX3AHFszHgoNAhnnyyxvXc8cYSeL7OxYzT04hxQ==} + /@teaxyz/lib/0.6.0: + resolution: {integrity: sha512-O9lYU/J1h+sbJApGcBUq4RlYymhfwB85k57hyaBhHq87DgXcR1xjhrKk0pfvn52sZT9jUoXH9UhPd1enWadXRQ==} dependencies: '@deno/shim-crypto': 0.3.1 '@deno/shim-deno': 0.16.1