mirror of
https://github.com/denoland/deno.git
synced 2025-01-07 06:46:59 -05:00
fix(ext/node): allow for the reassignment of userInfo() on Windows (#20165)
The goal of this PR is to address issue #20106 where a `TypeError` occurs when the variables `uid` and `gid` from `userInfo()` in `node:os` are reassigned if the user is on Windows. Both `uid` and `gid` are marked as `const` therefore producing a `TypeError` when the two are reassigned. This PR achieves that goal by marking `uid` and `gid` as `let`
This commit is contained in:
parent
1fd219fe8a
commit
3891997a97
2 changed files with 3 additions and 4 deletions
|
@ -216,7 +216,6 @@ if (common.isWindows && process.env.USERPROFILE) {
|
||||||
process.env.HOME = home;
|
process.env.HOME = home;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO(kt3k): Enable this test
|
|
||||||
const pwd = os.userInfo();
|
const pwd = os.userInfo();
|
||||||
is.object(pwd);
|
is.object(pwd);
|
||||||
const pwdBuf = os.userInfo({ encoding: 'buffer' });
|
const pwdBuf = os.userInfo({ encoding: 'buffer' });
|
||||||
|
@ -245,7 +244,7 @@ is.string(pwd.username);
|
||||||
assert.ok(pwd.homedir.includes(path.sep));
|
assert.ok(pwd.homedir.includes(path.sep));
|
||||||
assert.strictEqual(pwd.username, pwdBuf.username.toString('utf8'));
|
assert.strictEqual(pwd.username, pwdBuf.username.toString('utf8'));
|
||||||
assert.strictEqual(pwd.homedir, pwdBuf.homedir.toString('utf8'));
|
assert.strictEqual(pwd.homedir, pwdBuf.homedir.toString('utf8'));
|
||||||
*/
|
|
||||||
|
|
||||||
assert.strictEqual(`${os.hostname}`, os.hostname());
|
assert.strictEqual(`${os.hostname}`, os.hostname());
|
||||||
assert.strictEqual(`${os.homedir}`, os.homedir());
|
assert.strictEqual(`${os.homedir}`, os.homedir());
|
||||||
|
|
|
@ -320,8 +320,8 @@ export function uptime(): number {
|
||||||
export function userInfo(
|
export function userInfo(
|
||||||
options: UserInfoOptions = { encoding: "utf-8" },
|
options: UserInfoOptions = { encoding: "utf-8" },
|
||||||
): UserInfo {
|
): UserInfo {
|
||||||
const uid = Deno.uid();
|
let uid = Deno.uid();
|
||||||
const gid = Deno.gid();
|
let gid = Deno.gid();
|
||||||
|
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
uid = -1;
|
uid = -1;
|
||||||
|
|
Loading…
Reference in a new issue