(homeDir: string)
| 230 | * build that predates token auth. |
| 231 | */ |
| 232 | export function resolveServerToken(homeDir: string): string { |
| 233 | const tokenPath = join(homeDir, SERVER_TOKEN_FILE); |
| 234 | try { |
| 235 | return readFileSync(tokenPath, 'utf8').trim(); |
| 236 | } catch (error) { |
| 237 | throw new Error( |
| 238 | `unable to read server token at ${tokenPath}; has the server been started at least once?`, |
| 239 | { cause: error }, |
| 240 | ); |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | /** Best-effort token read: returns `undefined` instead of throwing. */ |
| 245 | export function tryResolveServerToken(homeDir: string): string | undefined { |
no outgoing calls
no test coverage detected