MCPcopy Index your code
hub / github.com/codeaashu/claude-code / findValidClaudeAlias

Function findValidClaudeAlias

src/utils/shellConfig.ts:142–167  ·  view source on GitHub ↗
(
  options?: ShellConfigOptions,
)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 2

findClaudeAliasFunction · 0.85
statFunction · 0.85

Tested by

no test coverage detected