mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
🐛 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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user