From 93483dc94d3ec44c193a43a461f93a3ea71c618c Mon Sep 17 00:00:00 2001 From: Armin Kunkel Date: Sun, 20 Aug 2023 05:59:22 +0200 Subject: [PATCH] use default tmp directory for constructing socket path --- src/_utils.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/_utils.ts b/src/_utils.ts index ba63665..414a122 100644 --- a/src/_utils.ts +++ b/src/_utils.ts @@ -1,5 +1,5 @@ -import { networkInterfaces, platform } from "node:os"; -import { relative } from "pathe"; +import { networkInterfaces, platform, tmpdir } from "node:os"; +import { relative, join } from "pathe"; import { colors } from "consola/utils"; import { ListenURL, ListenOptions } from "./types"; @@ -40,9 +40,13 @@ export function formatURL(url: string) { } export function getSocketPath(ipcSocketName: string) { - return platform() === "win32" - ? `\\\\?\\pipe\\${ipcSocketName || "listhen"}` - : `/tmp/${ipcSocketName || "listhen"}.socket`; + if (platform() === "win32") { + return `\\\\?\\pipe\\${ipcSocketName || "listhen"}`; + } + return join( + tmpdir(), + ipcSocketName ? `${ipcSocketName}.socket` : "listhen.socket", + ); } export const IPC_NOT_USED_NAME = "_____";