MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / findValidClaudeAlias

Function findValidClaudeAlias

source code/utils/shellConfig.ts:144–169  ·  view source on GitHub ↗
(
  options?: ShellConfigOptions,
)

Source from the content-addressed store, hash-verified

142 * @param options Optional overrides for testing (env, homedir)
143 */
144export async function findValidClaudeAlias(
145 options?: ShellConfigOptions,
146): Promise<string | null> {
147 const aliasTarget = await findClaudeAlias(options)
148 if (!aliasTarget) return null
149
150 const home = options?.homedir ?? osHomedir()
151
152 // Expand ~ to home directory
153 const expandedPath = aliasTarget.startsWith('~')
154 ? aliasTarget.replace('~', home)
155 : aliasTarget
156
157 // Check if the target exists and is executable
158 try {
159 const stats = await stat(expandedPath)
160 // Check if it's a file (could be executable or symlink)
161 if (stats.isFile() || stats.isSymbolicLink()) {
162 return aliasTarget
163 }
164 } catch {
165 // Target doesn't exist or can't be accessed
166 }
167
168 return null
169}

Callers 1

Calls 2

findClaudeAliasFunction · 0.85
statFunction · 0.85

Tested by

no test coverage detected