* Update this session's name in its PID registry file so ListPeers * can surface it. Best-effort: silently no-op if name is falsy, the * file doesn't exist (session not registered), or read/write fails.
(patch: Record<string, unknown>)
| 116 | * file doesn't exist (session not registered), or read/write fails. |
| 117 | */ |
| 118 | async function updatePidFile(patch: Record<string, unknown>): Promise<void> { |
| 119 | const pidFile = join(getSessionsDir(), `${process.pid}.json`) |
| 120 | try { |
| 121 | const data = jsonParse(await readFile(pidFile, 'utf8')) as Record< |
| 122 | string, |
| 123 | unknown |
| 124 | > |
| 125 | await writeFile(pidFile, jsonStringify({ ...data, ...patch })) |
| 126 | } catch (e) { |
| 127 | logForDebugging( |
| 128 | `[concurrentSessions] updatePidFile failed: ${errorMessage(e)}`, |
| 129 | ) |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | export async function updateSessionName( |
| 134 | name: string | undefined, |
no test coverage detected