From 4cb22aa7d12148aa28aeaf27dea9367ddae8e6d8 Mon Sep 17 00:00:00 2001 From: Ovenoboyo Date: Wed, 24 Aug 2022 17:18:13 +0530 Subject: [PATCH] Check if prefix is defined before checking for IPC Signed-off-by: Ovenoboyo --- src/discordRPC/ipcTransport.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/discordRPC/ipcTransport.ts b/src/discordRPC/ipcTransport.ts index f6cd3f0..71703da 100644 --- a/src/discordRPC/ipcTransport.ts +++ b/src/discordRPC/ipcTransport.ts @@ -38,15 +38,15 @@ export class IPCTransport { if (process.platform === 'win32') { return `\\\\?\\pipe\\discord-ipc-${id}` } - const { - env: { XDG_RUNTIME_DIR, TMPDIR, TMP, TEMP } - } = process - + const { XDG_RUNTIME_DIR, TMPDIR, TMP, TEMP } = process.env const prefix = [`${XDG_RUNTIME_DIR}/app/com.discordapp.Discord`, XDG_RUNTIME_DIR, TMPDIR, TMP, TEMP, '/tmp'] + for (const p of prefix) { - const path = `${p.replace(/\/$/, '')}/discord-ipc-${id}` - if (await this.tryAccess(path)) { - return path + if (p) { + const path = `${p.replace(/\/$/, '')}/discord-ipc-${id}` + if (await this.tryAccess(path)) { + return path + } } } return ''