MCPcopy Create free account
hub / github.com/JordanCoin/codemap / findAstGrepBinary

Function findAstGrepBinary

scanner/astgrep.go:159–174  ·  view source on GitHub ↗

findAstGrepBinary checks for "ast-grep" first, then "sg". Linux commonly ships a non-ast-grep "sg" binary, so candidates must identify themselves as ast-grep before we accept them.

()

Source from the content-addressed store, hash-verified

157// Linux commonly ships a non-ast-grep "sg" binary, so candidates must
158// identify themselves as ast-grep before we accept them.
159func findAstGrepBinary() string {
160 if bundled := findBundledAstGrepBinary(); bundled != "" {
161 return bundled
162 }
163
164 for _, candidate := range []string{"ast-grep", "sg"} {
165 path, err := exec.LookPath(candidate)
166 if err != nil {
167 continue
168 }
169 if isAstGrepBinary(path) {
170 return path
171 }
172 }
173 return ""
174}
175
176// Close cleans up temp rules directory
177func (s *AstGrepScanner) Close() {

Callers 1

NewAstGrepScannerFunction · 0.85

Calls 2

findBundledAstGrepBinaryFunction · 0.85
isAstGrepBinaryFunction · 0.85

Tested by

no test coverage detected