summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Ihrig <cjihrig@gmail.com>2022-10-26 16:37:48 -0400
committerGitHub <noreply@github.com>2022-10-26 16:37:48 -0400
commit37340e23865b17b1466a7e32997b0add96dd3806 (patch)
tree4e72b47e33d2cff14a8b62231a9fa0555e8492a0
parentf4f1f4f0b64030b744cfb43693af321ea8332bf4 (diff)
chore(unstable): rename Deno.getUid() and Deno.getGid() (#16432)
This commit renames `Deno.getUid()` to `Deno.uid()` and renames `Deno.getGid()` to `Deno.gid()`.
-rw-r--r--cli/dts/lib.deno.ns.d.ts4
-rw-r--r--cli/dts/lib.deno.unstable.d.ts8
-rw-r--r--cli/tests/unit/os_test.ts12
-rw-r--r--cli/tests/unit/permissions_test.ts4
-rw-r--r--runtime/js/30_os.js12
-rw-r--r--runtime/js/90_deno_ns.js4
-rw-r--r--runtime/ops/os.rs28
-rw-r--r--runtime/permissions.rs2
m---------test_util/std0
9 files changed, 37 insertions, 37 deletions
diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts
index 518b81edd..f9baddb06 100644
--- a/cli/dts/lib.deno.ns.d.ts
+++ b/cli/dts/lib.deno.ns.d.ts
@@ -3762,8 +3762,8 @@ declare namespace Deno {
| "systemMemoryInfo"
| "networkInterfaces"
| "osRelease"
- | "getUid"
- | "getGid";
+ | "uid"
+ | "gid";
}
/** The permission descriptor for the `allow-ffi` permissions, which controls
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts
index 2bcba88da..992e57185 100644
--- a/cli/dts/lib.deno.unstable.d.ts
+++ b/cli/dts/lib.deno.unstable.d.ts
@@ -359,7 +359,7 @@ declare namespace Deno {
* on Windows.
*
* ```ts
- * console.log(Deno.getUid());
+ * console.log(Deno.uid());
* ```
*
* Requires `allow-sys` permission.
@@ -367,7 +367,7 @@ declare namespace Deno {
* @tags allow-sys
* @category Runtime Environment
*/
- export function getUid(): number | null;
+ export function uid(): number | null;
/** **UNSTABLE**: New API, yet to be vetted.
*
@@ -375,7 +375,7 @@ declare namespace Deno {
* Windows.
*
* ```ts
- * console.log(Deno.getGid());
+ * console.log(Deno.gid());
* ```
*
* Requires `allow-sys` permission.
@@ -383,7 +383,7 @@ declare namespace Deno {
* @tags allow-sys
* @category Runtime Environment
*/
- export function getGid(): number | null;
+ export function gid(): number | null;
/** **UNSTABLE**: New API, yet to be vetted.
*
diff --git a/cli/tests/unit/os_test.ts b/cli/tests/unit/os_test.ts
index d620ae4e3..a7329ddb4 100644
--- a/cli/tests/unit/os_test.ts
+++ b/cli/tests/unit/os_test.ts
@@ -241,21 +241,21 @@ Deno.test(
},
);
-Deno.test({ permissions: { sys: ["getUid"] } }, function getUid() {
+Deno.test({ permissions: { sys: ["uid"] } }, function getUid() {
if (Deno.build.os === "windows") {
- assertEquals(Deno.getUid(), null);
+ assertEquals(Deno.uid(), null);
} else {
- const uid = Deno.getUid();
+ const uid = Deno.uid();
assert(typeof uid === "number");
assert(uid > 0);
}
});
-Deno.test({ permissions: { sys: ["getGid"] } }, function getGid() {
+Deno.test({ permissions: { sys: ["gid"] } }, function getGid() {
if (Deno.build.os === "windows") {
- assertEquals(Deno.getGid(), null);
+ assertEquals(Deno.gid(), null);
} else {
- const gid = Deno.getGid();
+ const gid = Deno.gid();
assert(typeof gid === "number");
assert(gid > 0);
}
diff --git a/cli/tests/unit/permissions_test.ts b/cli/tests/unit/permissions_test.ts
index c0945bb59..3387913e8 100644
--- a/cli/tests/unit/permissions_test.ts
+++ b/cli/tests/unit/permissions_test.ts
@@ -25,8 +25,8 @@ Deno.test(async function permissionSysValidKind() {
await Deno.permissions.query({ name: "sys", kind: "networkInterfaces" });
await Deno.permissions.query({ name: "sys", kind: "systemMemoryInfo" });
await Deno.permissions.query({ name: "sys", kind: "hostname" });
- await Deno.permissions.query({ name: "sys", kind: "getUid" });
- await Deno.permissions.query({ name: "sys", kind: "getGid" });
+ await Deno.permissions.query({ name: "sys", kind: "uid" });
+ await Deno.permissions.query({ name: "sys", kind: "gid" });
});
Deno.test(async function permissionSysInvalidKind() {
diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js
index 4fa71fa83..723b52132 100644
--- a/runtime/js/30_os.js
+++ b/runtime/js/30_os.js
@@ -33,12 +33,12 @@
return ops.op_network_interfaces();
}
- function getGid() {
- return ops.op_getgid();
+ function gid() {
+ return ops.op_gid();
}
- function getUid() {
- return ops.op_getuid();
+ function uid() {
+ return ops.op_uid();
}
// This is an internal only method used by the test harness to override the
@@ -101,13 +101,13 @@
env,
execPath,
exit,
- getGid,
- getUid,
+ gid,
hostname,
loadavg,
networkInterfaces,
osRelease,
setExitHandler,
systemMemoryInfo,
+ uid,
};
})(this);
diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js
index 00d343f74..1f949f512 100644
--- a/runtime/js/90_deno_ns.js
+++ b/runtime/js/90_deno_ns.js
@@ -128,8 +128,8 @@
osRelease: __bootstrap.os.osRelease,
systemMemoryInfo: __bootstrap.os.systemMemoryInfo,
networkInterfaces: __bootstrap.os.networkInterfaces,
- getGid: __bootstrap.os.getGid,
- getUid: __bootstrap.os.getUid,
+ gid: __bootstrap.os.gid,
+ uid: __bootstrap.os.uid,
listenDatagram: __bootstrap.net.listenDatagram,
umask: __bootstrap.fs.umask,
HttpClient: __bootstrap.fetch.HttpClient,
diff --git a/runtime/ops/os.rs b/runtime/ops/os.rs
index 2aafdc7a3..35b49217c 100644
--- a/runtime/ops/os.rs
+++ b/runtime/ops/os.rs
@@ -20,8 +20,7 @@ fn init_ops(builder: &mut ExtensionBuilder) -> &mut ExtensionBuilder {
op_exit::decl(),
op_delete_env::decl(),
op_get_env::decl(),
- op_getgid::decl(),
- op_getuid::decl(),
+ op_gid::decl(),
op_hostname::decl(),
op_loadavg::decl(),
op_network_interfaces::decl(),
@@ -29,6 +28,7 @@ fn init_ops(builder: &mut ExtensionBuilder) -> &mut ExtensionBuilder {
op_set_env::decl(),
op_set_exit_code::decl(),
op_system_memory_info::decl(),
+ op_uid::decl(),
])
}
@@ -284,12 +284,12 @@ fn op_system_memory_info(
#[cfg(not(windows))]
#[op]
-fn op_getgid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
- super::check_unstable(state, "Deno.getGid");
+fn op_gid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
+ super::check_unstable(state, "Deno.gid");
state
.borrow_mut::<Permissions>()
.sys
- .check("getGid", Some("Deno.getGid()"))?;
+ .check("gid", Some("Deno.gid()"))?;
// TODO(bartlomieju):
#[allow(clippy::undocumented_unsafe_blocks)]
unsafe {
@@ -299,23 +299,23 @@ fn op_getgid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
#[cfg(windows)]
#[op]
-fn op_getgid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
- super::check_unstable(state, "Deno.getGid");
+fn op_gid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
+ super::check_unstable(state, "Deno.gid");
state
.borrow_mut::<Permissions>()
.sys
- .check("getGid", Some("Deno.getGid()"))?;
+ .check("gid", Some("Deno.gid()"))?;
Ok(None)
}
#[cfg(not(windows))]
#[op]
-fn op_getuid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
- super::check_unstable(state, "Deno.getUid");
+fn op_uid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
+ super::check_unstable(state, "Deno.uid");
state
.borrow_mut::<Permissions>()
.sys
- .check("getUid", Some("Deno.getUid()"))?;
+ .check("uid", Some("Deno.uid()"))?;
// TODO(bartlomieju):
#[allow(clippy::undocumented_unsafe_blocks)]
unsafe {
@@ -325,11 +325,11 @@ fn op_getuid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
#[cfg(windows)]
#[op]
-fn op_getuid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
- super::check_unstable(state, "Deno.getUid");
+fn op_uid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
+ super::check_unstable(state, "Deno.uid");
state
.borrow_mut::<Permissions>()
.sys
- .check("getUid", Some("Deno.getUid()"))?;
+ .check("uid", Some("Deno.uid()"))?;
Ok(None)
}
diff --git a/runtime/permissions.rs b/runtime/permissions.rs
index ec2f146ae..95f95b512 100644
--- a/runtime/permissions.rs
+++ b/runtime/permissions.rs
@@ -308,7 +308,7 @@ pub struct SysDescriptor(pub String);
pub fn parse_sys_kind(kind: &str) -> Result<&str, AnyError> {
match kind {
"hostname" | "osRelease" | "loadavg" | "networkInterfaces"
- | "systemMemoryInfo" | "getUid" | "getGid" => Ok(kind),
+ | "systemMemoryInfo" | "uid" | "gid" => Ok(kind),
_ => Err(type_error(format!("unknown system info kind \"{}\"", kind))),
}
}
diff --git a/test_util/std b/test_util/std
-Subproject f2c97ea9c382fb3e225929c7650934417e2fc8c
+Subproject e26ced48ce65f1ab0e3bd2fc6e393b9ad526c6f