diff --git a/libraries/deno-commons-mod.ts b/libraries/deno-commons-mod.ts index ea81067..63f30b3 100644 --- a/libraries/deno-commons-mod.ts +++ b/libraries/deno-commons-mod.ts @@ -115,9 +115,9 @@ export async function execCommandShell( shell: false, stdio: ["inherit", "inherit", "inherit"], }); - ps.on('close', (code) => { + ps.on("close", (code) => { resolve(code); - }) + }); }); } } @@ -174,7 +174,7 @@ export function parseIntVal(val: any, defaultVal: number): number { } export function getEnv(envKey: string): string | null { - const homeDir = getHomeDir(); + const homeDir = homeDir(); if ((homeDir !== null) && envKey) { const envValue = readFileToStringSync( `${homeDir}/.config/envs/${envKey}`, @@ -653,7 +653,11 @@ class Logger { export const log = new Logger(); export function getHomeDirOrDie(): string { - const homeDir = getHomeDir(); + return homeDirOrDie(); +} + +export function homeDirOrDie(): string { + const homeDir = homeDir(); if (homeDir === null) { throw new Error("Cannot find home dir"); } @@ -661,6 +665,10 @@ export function getHomeDirOrDie(): string { } export function getHomeDir(): string | null { + return homeDir(); +} + +export function homeDir(): string | null { // if (Deno.build.os === "windows") { // const userProfile = Deno.env.get("USERPROFILE"); // if (userProfile) { @@ -673,12 +681,12 @@ export function getHomeDir(): string | null { // } // return null; // } - return osEnv("HOME") || null; + return osEnv("HOME") ?? null; } export function resolveFilename(filename: string): string { if (filename.startsWith("~/")) { - return getHomeDir() + filename.substring(1); + return homeDir() + filename.substring(1); } return filename; }