spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / telemetry / hooks / context / linux-distro-of / linux-distro-of.ts
26 lines · 659 BRaw
1import type { LinuxDistro } from './linux-distro'
2import { osReleaseValue } from './os-release-value'
3
4/**
5 * Reads the distribution's id and version off `/etc/os-release`, as the
6 * CLI's own rows do; a file that is missing or unreadable yields neither.
7 *
8 * @param readOsRelease reads `/etc/os-release` as text
9 * @returns the distribution
10 */
11export async function linuxDistroOf(
12 readOsRelease: () => Promise<string>,
13): Promise<LinuxDistro> {
14 let content: string
15
16 try {
17 content = await readOsRelease()
18 } catch {
19 content = ''
20 }
21
22 return {
23 id: osReleaseValue(content, 'ID'),
24 version: osReleaseValue(content, 'VERSION_ID'),
25 }
26}