Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

username

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

username - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0

19

index.js

@@ -27,2 +27,4 @@ 'use strict';

const makeUsernameFromId = userId => `no-username-${userId}`;
module.exports = mem(async () => {

@@ -39,2 +41,5 @@ const envVariable = getEnvironmentVariable();

/**
First we try to get the ID of the user and then the actual username. We do this because in `docker run --user <uid>:<gid>` context, we don't have "username" available. Therefore, we have a fallback to `makeUsernameFromId` for such scenario. Applies also to the `sync()` method below.
*/
try {

@@ -45,3 +50,8 @@ if (process.platform === 'win32') {

return await execa.stdout('id', ['-un']);
const userId = await execa.stdout('id', ['-u']);
try {
return await execa.stdout('id', ['-un', userId]);
} catch (_) {}
return makeUsernameFromId(userId);
} catch (_) {}

@@ -66,4 +76,9 @@ });

return execa.sync('id', ['-un']).stdout;
const userId = execa.sync('id', ['-u']).stdout;
try {
return execa.sync('id', ['-un', userId]).stdout;
} catch (_) {}
return makeUsernameFromId(userId);
} catch (_) {}
});

2

package.json
{
"name": "username",
"version": "5.0.0",
"version": "5.1.0",
"description": "Get the username of the current user",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc