generated from justjavac/deno_starter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mod.ts
20 lines (20 loc) · 847 Bytes
/
mod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/** Returns the path to the user's home directory.
*
* The returned value depends on the operating system and is either a string,
* containing a value from the following table, or `null`.
*
* |Platform | Value | Example |
* | ------- | -----------------------------------------| -----------------------|
* | Linux | `$HOME` | /home/justjavac |
* | macOS | `$HOME` | /Users/justjavac |
* | Windows | `$USERPROFILE` | C:\Users\justjavac |
*/
export default function home_dir(): string | null {
switch (Deno.build.os) {
case "linux":
case "darwin":
return Deno.env.get("HOME") ?? null;
case "windows":
return Deno.env.get("USERPROFILE") ?? null;
}
}