From 0fb07099a26128035138acd1eb7bf8116f1565f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Fri, 20 Nov 2020 00:23:47 +0100 Subject: [PATCH] fix for config file in home config --- cli.ts | 2 +- ui/zenity.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cli.ts b/cli.ts index 384b033..aca19db 100755 --- a/cli.ts +++ b/cli.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S deno run --allow-run --allow-read +#!/usr/bin/env -S deno run --allow-run --allow-read --allow-env import { showZenityUI } from "./ui/zenity.ts"; if (import.meta.main) { diff --git a/ui/zenity.ts b/ui/zenity.ts index bca710f..47d0865 100644 --- a/ui/zenity.ts +++ b/ui/zenity.ts @@ -32,7 +32,15 @@ async function copyToClipboard(text: string): Promise { } async function readPrivateKey(): Promise { - const content = await Deno.readTextFile(".local/config.json"); + let content: string; + try { + content = await Deno.readTextFile(".local/config.json"); + } catch { + content = await Deno.readTextFile( + `${Deno.env.get("HOME")}/.config/thunderk-passwordhash.json`, + ); + } + const config = JSON.parse(content); return config.privateKey; }