diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/dts/lib.deno.unstable.d.ts | 12 | ||||
-rw-r--r-- | cli/tests/unit/os_test.ts | 10 |
2 files changed, 22 insertions, 0 deletions
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index bc87ec02a..b8402cd9b 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -133,6 +133,18 @@ declare namespace Deno { */ export function networkInterfaces(): NetworkInterfaceInfo[]; + /** **Unstable** new API. yet to be vetted. + * + * Returns the user id of the process on POSIX platforms. Returns null on windows. + * + * ```ts + * console.log(Deno.getUid()); + * ``` + * + * Requires `allow-env` permission. + */ + export function getUid(): number | null; + /** All possible types for interfacing with foreign functions */ export type NativeType = | "void" diff --git a/cli/tests/unit/os_test.ts b/cli/tests/unit/os_test.ts index bd6bc5747..a469c8c9f 100644 --- a/cli/tests/unit/os_test.ts +++ b/cli/tests/unit/os_test.ts @@ -202,3 +202,13 @@ Deno.test({ permissions: { env: true } }, function systemMemoryInfo() { assert(info.swapTotal >= 0); assert(info.swapFree >= 0); }); + +Deno.test({ permissions: { env: true } }, function getUid() { + if (Deno.build.os === "windows") { + assertEquals(Deno.getUid(), null); + } else { + const uid = Deno.getUid(); + assert(typeof uid === "number"); + assert(uid > 0); + } +}); |