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 / wsl-version-of / wsl-version-of.ts
22 lines · 644 BRaw
1/**
2 * The WSL release a Linux kernel string names, as the CLI reads
3 * `/proc/version`: the digit after `WSL`, `1` for the `Microsoft` kernels.
4 *
5 * @param readProcVersion reads `/proc/version` as text
6 * @returns the WSL version, or undefined off WSL or when the file is unread
7 */
8export async function wslVersionOf(
9 readProcVersion: () => Promise<string>,
10): Promise<string | undefined> {
11 let kernel: string
12
13 try {
14 kernel = (await readProcVersion()).toLowerCase()
15 } catch {
16 return undefined
17 }
18
19 const isMicrosoft = kernel.includes('microsoft')
20
21 return /wsl(\d+)/.exec(kernel)?.[1] ?? (isMicrosoft ? '1' : undefined)
22}