Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: don't use getCheckedFunction() in userInfo() #22599

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions lib/os.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const {
getOSType: _getOSType,
getPriority: _getPriority,
getTotalMem,
getUserInfo: _getUserInfo,
getUserInfo,
getUptime,
isBigEndian,
setPriority: _setPriority
Expand All @@ -64,7 +64,6 @@ const getHostname = getCheckedFunction(_getHostname);
const getInterfaceAddresses = getCheckedFunction(_getInterfaceAddresses);
const getOSRelease = getCheckedFunction(_getOSRelease);
const getOSType = getCheckedFunction(_getOSType);
const getUserInfo = getCheckedFunction(_getUserInfo);

getFreeMem[Symbol.toPrimitive] = () => getFreeMem();
getHostname[Symbol.toPrimitive] = () => getHostname();
Expand Down Expand Up @@ -239,6 +238,19 @@ function getPriority(pid) {
return priority;
}

function userInfo(options) {
if (typeof options !== 'object')
options = null;

const ctx = {};
const user = getUserInfo(options, ctx);

if (user === undefined)
throw new ERR_SYSTEM_ERROR(ctx);

return user;
}

module.exports = {
arch,
cpus,
Expand All @@ -255,7 +267,7 @@ module.exports = {
tmpdir,
totalmem: getTotalMem,
type: getOSType,
userInfo: getUserInfo,
userInfo,
uptime: getUptime,

// Deprecated APIs
Expand Down