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 (_) {} | ||
}); |
{ | ||
"name": "username", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Get the username of the current user", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5848
94