From 8e8debe5beb00f4fc57976ded58604d995a3f4c7 Mon Sep 17 00:00:00 2001 From: Ben Richeson Date: Thu, 26 Aug 2021 22:02:02 -0400 Subject: [PATCH] Fix path on MacOS Credit: discordjs/RPC#113 --- src/transports/ipc.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/transports/ipc.js b/src/transports/ipc.js index f050a01..cd9464b 100644 --- a/src/transports/ipc.js +++ b/src/transports/ipc.js @@ -1,5 +1,7 @@ 'use strict'; +const os = require('os'); +const path = require('path'); const net = require('net'); const EventEmitter = require('events'); const fetch = require('node-fetch'); @@ -17,6 +19,15 @@ function getIPCPath(id) { if (process.platform === 'win32') { return `\\\\?\\pipe\\discord-ipc-${id}`; } + + if (process.platform === 'darwin') { + let tmpdir = os.tmpdir(); + if (!tmpdir.endsWith('/T')) { + tmpdir = path.dirname(tmpdir); + } + return `${tmpdir}/discord-ipc-${id}`; + } + const { env: { XDG_RUNTIME_DIR, TMPDIR, TMP, TEMP } } = process; const prefix = XDG_RUNTIME_DIR || TMPDIR || TMP || TEMP || '/tmp'; return `${prefix.replace(/\/$/, '')}/discord-ipc-${id}`;