feat: udpate deno-commons-mod.ts

This commit is contained in:
2026-01-11 23:51:42 +08:00
parent 0b0bc45918
commit de7d85fdc9

View File

@@ -37,8 +37,21 @@ export function isOn(val: string | undefined): boolean {
lowerVal === "true"; lowerVal === "true";
} }
export async function getEnv(key: string): string {
const homeDir = getHomeDir();
if ((homeDir !== null) && key) {
const envValue = await readFileToString(
`${homeDir}/.config/envs/${key}`,
);
if (envValue !== null) {
return envValue.trim();
}
}
return Deno.env.get(key);
}
export function isEnvOn(envKey: string): boolean { export function isEnvOn(envKey: string): boolean {
return isOn(Deno.env.get(envKey)); return isOn(getEnv(envKey));
} }
export function formatHumanTime(timeMillis: number): string { export function formatHumanTime(timeMillis: number): string {