diff options
Diffstat (limited to 'os/mod.ts')
-rw-r--r-- | os/mod.ts | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/os/mod.ts b/os/mod.ts deleted file mode 100644 index a2bb0457b..000000000 --- a/os/mod.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. - -/** - * Returns the current user's home directory. - * On Unix, including macOS, it returns the $HOME environment variable. - * On Windows, it returns %USERPROFILE%. - * Needs permissions to access env (--allow-env). - * - * Ported from Go: https://github.com/golang/go/blob/go1.12.5/src/os/file.go#L389 - */ -export function userHomeDir(): string { - let env = "HOME"; - let envErr = "$HOME"; - - if (Deno.platform.os === "win") { - env = "USERPROFILE"; - envErr = "%USERPROFILE%"; - } - - const value = Deno.env()[env]; - if (value !== "") { - return value; - } - - throw new Error(`Environment variable '${envErr}' is not defined.`); -} |