mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
chore(unstable): rename Deno.getUid() and Deno.getGid() (#16432)
This commit renames `Deno.getUid()` to `Deno.uid()` and renames `Deno.getGid()` to `Deno.gid()`.
This commit is contained in:
parent
f4f1f4f0b6
commit
37340e2386
9 changed files with 38 additions and 38 deletions
4
cli/dts/lib.deno.ns.d.ts
vendored
4
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -3762,8 +3762,8 @@ declare namespace Deno {
|
||||||
| "systemMemoryInfo"
|
| "systemMemoryInfo"
|
||||||
| "networkInterfaces"
|
| "networkInterfaces"
|
||||||
| "osRelease"
|
| "osRelease"
|
||||||
| "getUid"
|
| "uid"
|
||||||
| "getGid";
|
| "gid";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The permission descriptor for the `allow-ffi` permissions, which controls
|
/** The permission descriptor for the `allow-ffi` permissions, which controls
|
||||||
|
|
8
cli/dts/lib.deno.unstable.d.ts
vendored
8
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -359,7 +359,7 @@ declare namespace Deno {
|
||||||
* on Windows.
|
* on Windows.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* console.log(Deno.getUid());
|
* console.log(Deno.uid());
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-sys` permission.
|
* Requires `allow-sys` permission.
|
||||||
|
@ -367,7 +367,7 @@ declare namespace Deno {
|
||||||
* @tags allow-sys
|
* @tags allow-sys
|
||||||
* @category Runtime Environment
|
* @category Runtime Environment
|
||||||
*/
|
*/
|
||||||
export function getUid(): number | null;
|
export function uid(): number | null;
|
||||||
|
|
||||||
/** **UNSTABLE**: New API, yet to be vetted.
|
/** **UNSTABLE**: New API, yet to be vetted.
|
||||||
*
|
*
|
||||||
|
@ -375,7 +375,7 @@ declare namespace Deno {
|
||||||
* Windows.
|
* Windows.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* console.log(Deno.getGid());
|
* console.log(Deno.gid());
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* Requires `allow-sys` permission.
|
* Requires `allow-sys` permission.
|
||||||
|
@ -383,7 +383,7 @@ declare namespace Deno {
|
||||||
* @tags allow-sys
|
* @tags allow-sys
|
||||||
* @category Runtime Environment
|
* @category Runtime Environment
|
||||||
*/
|
*/
|
||||||
export function getGid(): number | null;
|
export function gid(): number | null;
|
||||||
|
|
||||||
/** **UNSTABLE**: New API, yet to be vetted.
|
/** **UNSTABLE**: New API, yet to be vetted.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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") {
|
if (Deno.build.os === "windows") {
|
||||||
assertEquals(Deno.getUid(), null);
|
assertEquals(Deno.uid(), null);
|
||||||
} else {
|
} else {
|
||||||
const uid = Deno.getUid();
|
const uid = Deno.uid();
|
||||||
assert(typeof uid === "number");
|
assert(typeof uid === "number");
|
||||||
assert(uid > 0);
|
assert(uid > 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test({ permissions: { sys: ["getGid"] } }, function getGid() {
|
Deno.test({ permissions: { sys: ["gid"] } }, function getGid() {
|
||||||
if (Deno.build.os === "windows") {
|
if (Deno.build.os === "windows") {
|
||||||
assertEquals(Deno.getGid(), null);
|
assertEquals(Deno.gid(), null);
|
||||||
} else {
|
} else {
|
||||||
const gid = Deno.getGid();
|
const gid = Deno.gid();
|
||||||
assert(typeof gid === "number");
|
assert(typeof gid === "number");
|
||||||
assert(gid > 0);
|
assert(gid > 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ Deno.test(async function permissionSysValidKind() {
|
||||||
await Deno.permissions.query({ name: "sys", kind: "networkInterfaces" });
|
await Deno.permissions.query({ name: "sys", kind: "networkInterfaces" });
|
||||||
await Deno.permissions.query({ name: "sys", kind: "systemMemoryInfo" });
|
await Deno.permissions.query({ name: "sys", kind: "systemMemoryInfo" });
|
||||||
await Deno.permissions.query({ name: "sys", kind: "hostname" });
|
await Deno.permissions.query({ name: "sys", kind: "hostname" });
|
||||||
await Deno.permissions.query({ name: "sys", kind: "getUid" });
|
await Deno.permissions.query({ name: "sys", kind: "uid" });
|
||||||
await Deno.permissions.query({ name: "sys", kind: "getGid" });
|
await Deno.permissions.query({ name: "sys", kind: "gid" });
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(async function permissionSysInvalidKind() {
|
Deno.test(async function permissionSysInvalidKind() {
|
||||||
|
|
|
@ -33,12 +33,12 @@
|
||||||
return ops.op_network_interfaces();
|
return ops.op_network_interfaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGid() {
|
function gid() {
|
||||||
return ops.op_getgid();
|
return ops.op_gid();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUid() {
|
function uid() {
|
||||||
return ops.op_getuid();
|
return ops.op_uid();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is an internal only method used by the test harness to override the
|
// This is an internal only method used by the test harness to override the
|
||||||
|
@ -101,13 +101,13 @@
|
||||||
env,
|
env,
|
||||||
execPath,
|
execPath,
|
||||||
exit,
|
exit,
|
||||||
getGid,
|
gid,
|
||||||
getUid,
|
|
||||||
hostname,
|
hostname,
|
||||||
loadavg,
|
loadavg,
|
||||||
networkInterfaces,
|
networkInterfaces,
|
||||||
osRelease,
|
osRelease,
|
||||||
setExitHandler,
|
setExitHandler,
|
||||||
systemMemoryInfo,
|
systemMemoryInfo,
|
||||||
|
uid,
|
||||||
};
|
};
|
||||||
})(this);
|
})(this);
|
||||||
|
|
|
@ -128,8 +128,8 @@
|
||||||
osRelease: __bootstrap.os.osRelease,
|
osRelease: __bootstrap.os.osRelease,
|
||||||
systemMemoryInfo: __bootstrap.os.systemMemoryInfo,
|
systemMemoryInfo: __bootstrap.os.systemMemoryInfo,
|
||||||
networkInterfaces: __bootstrap.os.networkInterfaces,
|
networkInterfaces: __bootstrap.os.networkInterfaces,
|
||||||
getGid: __bootstrap.os.getGid,
|
gid: __bootstrap.os.gid,
|
||||||
getUid: __bootstrap.os.getUid,
|
uid: __bootstrap.os.uid,
|
||||||
listenDatagram: __bootstrap.net.listenDatagram,
|
listenDatagram: __bootstrap.net.listenDatagram,
|
||||||
umask: __bootstrap.fs.umask,
|
umask: __bootstrap.fs.umask,
|
||||||
HttpClient: __bootstrap.fetch.HttpClient,
|
HttpClient: __bootstrap.fetch.HttpClient,
|
||||||
|
|
|
@ -20,8 +20,7 @@ fn init_ops(builder: &mut ExtensionBuilder) -> &mut ExtensionBuilder {
|
||||||
op_exit::decl(),
|
op_exit::decl(),
|
||||||
op_delete_env::decl(),
|
op_delete_env::decl(),
|
||||||
op_get_env::decl(),
|
op_get_env::decl(),
|
||||||
op_getgid::decl(),
|
op_gid::decl(),
|
||||||
op_getuid::decl(),
|
|
||||||
op_hostname::decl(),
|
op_hostname::decl(),
|
||||||
op_loadavg::decl(),
|
op_loadavg::decl(),
|
||||||
op_network_interfaces::decl(),
|
op_network_interfaces::decl(),
|
||||||
|
@ -29,6 +28,7 @@ fn init_ops(builder: &mut ExtensionBuilder) -> &mut ExtensionBuilder {
|
||||||
op_set_env::decl(),
|
op_set_env::decl(),
|
||||||
op_set_exit_code::decl(),
|
op_set_exit_code::decl(),
|
||||||
op_system_memory_info::decl(),
|
op_system_memory_info::decl(),
|
||||||
|
op_uid::decl(),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,12 +284,12 @@ fn op_system_memory_info(
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
#[op]
|
#[op]
|
||||||
fn op_getgid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
fn op_gid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
||||||
super::check_unstable(state, "Deno.getGid");
|
super::check_unstable(state, "Deno.gid");
|
||||||
state
|
state
|
||||||
.borrow_mut::<Permissions>()
|
.borrow_mut::<Permissions>()
|
||||||
.sys
|
.sys
|
||||||
.check("getGid", Some("Deno.getGid()"))?;
|
.check("gid", Some("Deno.gid()"))?;
|
||||||
// TODO(bartlomieju):
|
// TODO(bartlomieju):
|
||||||
#[allow(clippy::undocumented_unsafe_blocks)]
|
#[allow(clippy::undocumented_unsafe_blocks)]
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -299,23 +299,23 @@ fn op_getgid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[op]
|
#[op]
|
||||||
fn op_getgid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
fn op_gid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
||||||
super::check_unstable(state, "Deno.getGid");
|
super::check_unstable(state, "Deno.gid");
|
||||||
state
|
state
|
||||||
.borrow_mut::<Permissions>()
|
.borrow_mut::<Permissions>()
|
||||||
.sys
|
.sys
|
||||||
.check("getGid", Some("Deno.getGid()"))?;
|
.check("gid", Some("Deno.gid()"))?;
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
#[op]
|
#[op]
|
||||||
fn op_getuid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
fn op_uid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
||||||
super::check_unstable(state, "Deno.getUid");
|
super::check_unstable(state, "Deno.uid");
|
||||||
state
|
state
|
||||||
.borrow_mut::<Permissions>()
|
.borrow_mut::<Permissions>()
|
||||||
.sys
|
.sys
|
||||||
.check("getUid", Some("Deno.getUid()"))?;
|
.check("uid", Some("Deno.uid()"))?;
|
||||||
// TODO(bartlomieju):
|
// TODO(bartlomieju):
|
||||||
#[allow(clippy::undocumented_unsafe_blocks)]
|
#[allow(clippy::undocumented_unsafe_blocks)]
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -325,11 +325,11 @@ fn op_getuid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[op]
|
#[op]
|
||||||
fn op_getuid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
fn op_uid(state: &mut OpState) -> Result<Option<u32>, AnyError> {
|
||||||
super::check_unstable(state, "Deno.getUid");
|
super::check_unstable(state, "Deno.uid");
|
||||||
state
|
state
|
||||||
.borrow_mut::<Permissions>()
|
.borrow_mut::<Permissions>()
|
||||||
.sys
|
.sys
|
||||||
.check("getUid", Some("Deno.getUid()"))?;
|
.check("uid", Some("Deno.uid()"))?;
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,7 @@ pub struct SysDescriptor(pub String);
|
||||||
pub fn parse_sys_kind(kind: &str) -> Result<&str, AnyError> {
|
pub fn parse_sys_kind(kind: &str) -> Result<&str, AnyError> {
|
||||||
match kind {
|
match kind {
|
||||||
"hostname" | "osRelease" | "loadavg" | "networkInterfaces"
|
"hostname" | "osRelease" | "loadavg" | "networkInterfaces"
|
||||||
| "systemMemoryInfo" | "getUid" | "getGid" => Ok(kind),
|
| "systemMemoryInfo" | "uid" | "gid" => Ok(kind),
|
||||||
_ => Err(type_error(format!("unknown system info kind \"{}\"", kind))),
|
_ => Err(type_error(format!("unknown system info kind \"{}\"", kind))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit f2c97ea9c382fb3e225929c7650934417e2fc8c9
|
Subproject commit e26ced48ce65f1ab0e3bd2fc6e393b9ad526c6fe
|
Loading…
Reference in a new issue