MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / extractPipePositions

Function extractPipePositions

src/utils/bash/ParsedCommand.ts:113–129  ·  view source on GitHub ↗
(rootNode: Node)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 2

visitNodesFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected