From 26a29e328361b296672b92b07abd03987267d8e6 Mon Sep 17 00:00:00 2001 From: Sam Jakob Mearns Date: Tue, 2 Feb 2021 22:39:29 +0000 Subject: [PATCH 1/3] Attempt to patch getIPCPath for macOS --- src/transports/ipc.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/transports/ipc.js b/src/transports/ipc.js index f050a01..5068b18 100644 --- a/src/transports/ipc.js +++ b/src/transports/ipc.js @@ -1,5 +1,6 @@ 'use strict'; +const os = require('os'); const net = require('net'); const EventEmitter = require('events'); const fetch = require('node-fetch'); @@ -17,6 +18,9 @@ function getIPCPath(id) { if (process.platform === 'win32') { return `\\\\?\\pipe\\discord-ipc-${id}`; } + if (process.platform === 'darwin') { + return `${os.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}`; From d91050ecd843f030fe27fdc3ed6405ac7a79959c Mon Sep 17 00:00:00 2001 From: Sam Jakob Mearns Date: Tue, 2 Feb 2021 23:01:05 +0000 Subject: [PATCH 2/3] Fix getIPCPath on darwin under a parent process --- src/transports/ipc.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/transports/ipc.js b/src/transports/ipc.js index 5068b18..37d9d98 100644 --- a/src/transports/ipc.js +++ b/src/transports/ipc.js @@ -19,7 +19,11 @@ function getIPCPath(id) { return `\\\\?\\pipe\\discord-ipc-${id}`; } if (process.platform === 'darwin') { - return `${os.tmpdir()}/discord-ipc-${id}`; + let tmpdir = os.tmpdir(); + if (!tmpdir.endsWith('/T')) { + tmpdir += '/..'; + } + return `${tmpdir}/discord-ipc-${id}`; } const { env: { XDG_RUNTIME_DIR, TMPDIR, TMP, TEMP } } = process; const prefix = XDG_RUNTIME_DIR || TMPDIR || TMP || TEMP || '/tmp'; From 52e586ef017ff443daea5a16f6b12cd0c558e62b Mon Sep 17 00:00:00 2001 From: SamJakob Date: Wed, 3 Feb 2021 15:14:30 +0000 Subject: [PATCH 3/3] Use path.dirname to obtain parent directory --- src/transports/ipc.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/transports/ipc.js b/src/transports/ipc.js index 37d9d98..37627ff 100644 --- a/src/transports/ipc.js +++ b/src/transports/ipc.js @@ -1,6 +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'); @@ -21,7 +22,7 @@ function getIPCPath(id) { if (process.platform === 'darwin') { let tmpdir = os.tmpdir(); if (!tmpdir.endsWith('/T')) { - tmpdir += '/..'; + tmpdir = path.dirname(tmpdir); } return `${tmpdir}/discord-ipc-${id}`; }