mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -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
346a3360b2
commit
08b9f920f6
2 changed files with 3 additions and 4 deletions
|
@ -216,7 +216,6 @@ if (common.isWindows && process.env.USERPROFILE) {
|
|||
process.env.HOME = home;
|
||||
}
|
||||
|
||||
/* TODO(kt3k): Enable this test
|
||||
const pwd = os.userInfo();
|
||||
is.object(pwd);
|
||||
const pwdBuf = os.userInfo({ encoding: 'buffer' });
|
||||
|
@ -245,7 +244,7 @@ is.string(pwd.username);
|
|||
assert.ok(pwd.homedir.includes(path.sep));
|
||||
assert.strictEqual(pwd.username, pwdBuf.username.toString('utf8'));
|
||||
assert.strictEqual(pwd.homedir, pwdBuf.homedir.toString('utf8'));
|
||||
*/
|
||||
|
||||
|
||||
assert.strictEqual(`${os.hostname}`, os.hostname());
|
||||
assert.strictEqual(`${os.homedir}`, os.homedir());
|
||||
|
|
|
@ -320,8 +320,8 @@ export function uptime(): number {
|
|||
export function userInfo(
|
||||
options: UserInfoOptions = { encoding: "utf-8" },
|
||||
): UserInfo {
|
||||
const uid = Deno.uid();
|
||||
const gid = Deno.gid();
|
||||
let uid = Deno.uid();
|
||||
let gid = Deno.gid();
|
||||
|
||||
if (isWindows) {
|
||||
uid = -1;
|
||||
|
|
Loading…
Reference in a new issue