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 / identity / global-config-path / global-config-path.ts
19 lines · 698 BRaw
1import type { ConfigLocation } from '../../../config-location'
2
3/**
4 * Where the CLI keeps its global config: `.claude.json` under the config
5 * directory when one is named, else under the home or profile directory.
6 *
7 * @param location the three variables as read
8 * @returns the file's path, or undefined when no directory is named
9 */
10export function globalConfigPath(location: ConfigLocation): string | undefined {
11 const directory = location.configDir || location.home || location.userProfile
12
13 const separator =
14 directory?.includes('\\') && !directory.includes('/') ? '\\' : '/'
15
16 return directory
17 ? `${directory.replace(/[\\/]+$/, '')}${separator}.claude.json`
18 : undefined
19}