feat: updates deno-commons-mod.ts

This commit is contained in:
2025-09-09 22:45:48 +08:00
parent 117689a942
commit 8f7e49ffcc

View File

@@ -238,7 +238,16 @@ export const log = new Logger();
export function getHomeDir(): string | null { export function getHomeDir(): string | null {
if (Deno.build.os === "windows") { if (Deno.build.os === "windows") {
return Deno.env.get("USERPROFILE") || Deno.env.get("HOMEDRIVE") + Deno.env.get("HOMEPATH") || null; const userProfile = Deno.env.get("USERPROFILE");
if (userProfile) {
return userProfile;
}
const homeDrive = Deno.env.get("HOMEDRIVE");
const homePath = Deno.env.get("HOMEPATH");
if (homeDrive && homePath) {
return homeDrive + homePath;
}
return null;
} }
return Deno.env.get("HOME") || null; return Deno.env.get("HOME") || null;
} }