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

Function handleWrapper

source code/utils/bash/prefix.ts:74–123  ·  view source on GitHub ↗
(
  command: string,
  args: string[],
  recursionDepth: number,
  wrapperCount: number,
)

Source from the content-addressed store, hash-verified

72}
73
74async function handleWrapper(
75 command: string,
76 args: string[],
77 recursionDepth: number,
78 wrapperCount: number,
79): Promise<string | null> {
80 const spec = await getCommandSpec(command)
81
82 if (spec?.args) {
83 const commandArgIndex = toArray(spec.args).findIndex(arg => arg?.isCommand)
84
85 if (commandArgIndex !== -1) {
86 const parts = [command]
87
88 for (let i = 0; i < args.length && i <= commandArgIndex; i++) {
89 if (i === commandArgIndex) {
90 const result = await getCommandPrefixStatic(
91 args.slice(i).join(' '),
92 recursionDepth + 1,
93 wrapperCount + 1,
94 )
95 if (result?.commandPrefix) {
96 parts.push(...result.commandPrefix.split(' '))
97 return parts.join(' ')
98 }
99 break
100 } else if (
101 args[i] &&
102 !args[i]!.startsWith('-') &&
103 !ENV_VAR.test(args[i]!)
104 ) {
105 parts.push(args[i]!)
106 }
107 }
108 }
109 }
110
111 const wrapped = args.find(
112 arg => !arg.startsWith('-') && !NUMERIC.test(arg) && !ENV_VAR.test(arg),
113 )
114 if (!wrapped) return command
115
116 const result = await getCommandPrefixStatic(
117 args.slice(args.indexOf(wrapped)).join(' '),
118 recursionDepth + 1,
119 wrapperCount + 1,
120 )
121
122 return !result?.commandPrefix ? null : `${command} ${result.commandPrefix}`
123}
124
125/**
126 * Computes prefixes for a compound command (with && / || / ;).

Callers 1

getCommandPrefixStaticFunction · 0.85

Calls 2

toArrayFunction · 0.70
getCommandPrefixStaticFunction · 0.70

Tested by

no test coverage detected