summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorJames Bradlee <post@jamesb.no>2022-05-31 10:42:44 +0200
committerGitHub <noreply@github.com>2022-05-31 17:42:44 +0900
commitc41544ac7b502fbdb6c1ee96a604490b72eb7770 (patch)
treee2b855a0c722feddf170ffb11c2a7f756a7f1e56 /cli
parentd9ed5e905c25bd415b5e65649a44e0a1580e5ed1 (diff)
feat(unstable): add Deno.getGid (#14528)
Diffstat (limited to 'cli')
-rw-r--r--cli/dts/lib.deno.unstable.d.ts12
-rw-r--r--cli/tests/unit/os_test.ts10
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 0ed27c5d5..b8eb886e4 100644
--- a/cli/dts/lib.deno.unstable.d.ts
+++ b/cli/dts/lib.deno.unstable.d.ts
@@ -317,6 +317,18 @@ declare namespace Deno {
*/
export function getUid(): number | null;
+ /** **Unstable** new API. yet to be vetted.
+ *
+ * Returns the group id of the process on POSIX platforms. Returns null on windows.
+ *
+ * ```ts
+ * console.log(Deno.getGid());
+ * ```
+ *
+ * Requires `allow-env` permission.
+ */
+ export function getGid(): 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 6ed1126f1..b5ff6f29f 100644
--- a/cli/tests/unit/os_test.ts
+++ b/cli/tests/unit/os_test.ts
@@ -204,3 +204,13 @@ Deno.test({ permissions: { env: true } }, function getUid() {
assert(uid > 0);
}
});
+
+Deno.test({ permissions: { env: true } }, function getGid() {
+ if (Deno.build.os === "windows") {
+ assertEquals(Deno.getGid(), null);
+ } else {
+ const gid = Deno.getGid();
+ assert(typeof gid === "number");
+ assert(gid > 0);
+ }
+});