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

Function extractPipePositions

source code/utils/bash/ParsedCommand.ts:115–131  ·  view source on GitHub ↗
(rootNode: Node)

Source from the content-addressed store, hash-verified

113}
114
115function extractPipePositions(rootNode: Node): number[] {
116 const pipePositions: number[] = []
117 visitNodes(rootNode, node => {
118 if (node.type === 'pipeline') {
119 for (const child of node.children) {
120 if (child.type === '|') {
121 pipePositions.push(child.startIndex)
122 }
123 }
124 }
125 })
126 // visitNodes is depth-first. For `a | b && c | d`, the outer `list` nests
127 // the second pipeline as a sibling of the first, so the outer `|` is
128 // visited before the inner one — positions arrive out of order.
129 // getPipeSegments iterates them to slice left-to-right, so sort here.
130 return pipePositions.sort((a, b) => a - b)
131}
132
133function extractRedirectionNodes(rootNode: Node): RedirectionNode[] {
134 const redirections: RedirectionNode[] = []

Callers 1

Calls 1

visitNodesFunction · 0.85

Tested by

no test coverage detected