Skip to content

Commit

Permalink
feat(std/node): add implementation of os.homedir() (#873)
Browse files Browse the repository at this point in the history
Co-authored-by: Yoshiya Hinosawa <[email protected]>
  • Loading branch information
arwtyxouymz and kt3k authored Apr 28, 2021
1 parent 2be830a commit 2509338
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion node/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,15 @@ export function getPriority(pid = 0): number {

/** Returns the string path of the current user's home directory. */
export function homedir(): string | null {
notImplemented(SEE_GITHUB_ISSUE);
switch (Deno.build.os) {
case "windows":
return Deno.env.get("USERPROFILE") || null;
case "linux":
case "darwin":
return Deno.env.get("HOME") || null;
default:
throw Error("unreachable");
}
}

/** Returns the host name of the operating system as a string. */
Expand Down

0 comments on commit 2509338

Please sign in to comment.