fix for config file in home config

This commit is contained in:
Michaël Lemaire 2020-11-20 00:23:47 +01:00
parent 54fd85694d
commit 0fb07099a2
2 changed files with 10 additions and 2 deletions

2
cli.ts
View file

@ -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) {

View file

@ -32,7 +32,15 @@ async function copyToClipboard(text: string): Promise<void> {
}
async function readPrivateKey(): Promise<string> {
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;
}