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.
()
| 157 | // Linux commonly ships a non-ast-grep "sg" binary, so candidates must |
| 158 | // identify themselves as ast-grep before we accept them. |
| 159 | func 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 |
| 177 | func (s *AstGrepScanner) Close() { |
no test coverage detected