🐛 Handle empty username

If Atom is launched in a shell that is missing the `USER`/`USERNAME`
environment variable it locks up due to an unhandled error from
`crypto.update`. This switches to using Node.js's built in
`os.userInfo()` method to retrieve the current user name,
allowing Atom to complete initialization in this scenario.

Fixes #16821.
This commit is contained in:
Landon Abney
2018-02-22 12:21:21 -08:00
parent fa9c8d1ace
commit 138115f2a8

View File

@@ -33,7 +33,7 @@ class AtomApplication extends EventEmitter {
// Public: The entry point into the Atom application.
static open (options) {
if (!options.socketPath) {
const username = process.platform === 'win32' ? process.env.USERNAME : process.env.USER
const {username} = os.userInfo()
// Lowercasing the ATOM_HOME to make sure that we don't get multiple sockets
// on case-insensitive filesystems due to arbitrary case differences in paths.
@@ -44,7 +44,7 @@ class AtomApplication extends EventEmitter {
.update('|')
.update(process.arch)
.update('|')
.update(username)
.update(username || '')
.update('|')
.update(atomHomeUnique)