MCPcopy Index your code
hub / github.com/liuup/claude-code-analysis / getCommandSubcommandPrefixImpl

Function getCommandSubcommandPrefixImpl

src/utils/shell/prefix.ts:332–367  ·  view source on GitHub ↗
(
  command: string,
  abortSignal: AbortSignal,
  isNonInteractiveSession: boolean,
  getPrefix: ReturnType<typeof createCommandPrefixExtractor>,
  splitCommandFn: (command: string) => string[] | Promise<string[]>,
)

Source from the content-addressed store, hash-verified

330}
331
332async function getCommandSubcommandPrefixImpl(
333 command: string,
334 abortSignal: AbortSignal,
335 isNonInteractiveSession: boolean,
336 getPrefix: ReturnType<typeof createCommandPrefixExtractor>,
337 splitCommandFn: (command: string) => string[] | Promise<string[]>,
338): Promise<CommandSubcommandPrefixResult | null> {
339 const subcommands = await splitCommandFn(command)
340
341 const [fullCommandPrefix, ...subcommandPrefixesResults] = await Promise.all([
342 getPrefix(command, abortSignal, isNonInteractiveSession),
343 ...subcommands.map(async subcommand => ({
344 subcommand,
345 prefix: await getPrefix(subcommand, abortSignal, isNonInteractiveSession),
346 })),
347 ])
348
349 if (!fullCommandPrefix) {
350 return null
351 }
352
353 const subcommandPrefixes = subcommandPrefixesResults.reduce(
354 (acc, { subcommand, prefix }) => {
355 if (prefix) {
356 acc.set(subcommand, prefix)
357 }
358 return acc
359 },
360 new Map<string, CommandPrefixResult>(),
361 )
362
363 return {
364 ...fullCommandPrefix,
365 subcommandPrefixes,
366 }
367}

Callers 1

Calls 1

setMethod · 0.80

Tested by

no test coverage detected