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
| 1 | import type { TelemetryDeps } from '../../../telemetry-deps' |
| 2 | import { linuxDistroOf } from '../../linux-distro-of' |
| 3 | import { wslVersionOf } from '../../wsl-version-of' |
| 4 | import type { LinuxFiles } from '../linux-files' |
| 5 | |
| 6 | /** |
| 7 | * Reads the four Linux files the rows draw on, on Linux alone; elsewhere, |
| 8 | * and for each file that cannot be read, the answer is empty. |
| 9 | * |
| 10 | * @param deps the calls on the nouns beneath |
| 11 | * @param isLinux whether the machine named itself Linux |
| 12 | * @returns what the files say |
| 13 | */ |
| 14 | export async function linuxFilesOf( |
| 15 | deps: TelemetryDeps, |
| 16 | isLinux: boolean, |
| 17 | ): Promise<LinuxFiles> { |
| 18 | const [distro, wslVersion, isEc2, isDocker] = await Promise.all([ |
| 19 | isLinux |
| 20 | ? linuxDistroOf(() => deps.read('/etc/os-release')) |
| 21 | : { id: undefined, version: undefined }, |
| 22 | isLinux ? wslVersionOf(() => deps.read('/proc/version')) : undefined, |
| 23 | isLinux |
| 24 | ? deps.read('/sys/hypervisor/uuid').then( |
| 25 | uuid => uuid.startsWith('ec2'), |
| 26 | () => false, |
| 27 | ) |
| 28 | : false, |
| 29 | isLinux ? deps.exists('/.dockerenv').catch(() => false) : false, |
| 30 | ]) |
| 31 | |
| 32 | return { |
| 33 | distro, |
| 34 | wslVersion, |
| 35 | fileSignals: [ |
| 36 | ['aws-ec2', isEc2], |
| 37 | ['docker', isDocker], |
| 38 | ], |
| 39 | } |
| 40 | } |