()
| 63 | * @returns Object with type and the shell snippet to use |
| 64 | */ |
| 65 | export function createRipgrepShellIntegration(): { |
| 66 | type: 'alias' | 'function' |
| 67 | snippet: string |
| 68 | } { |
| 69 | const rgCommand = ripgrepCommand() |
| 70 | |
| 71 | // For embedded ripgrep (bun-internal), we need a shell function that sets argv0 |
| 72 | if (rgCommand.argv0) { |
| 73 | return { |
| 74 | type: 'function', |
| 75 | snippet: createArgv0ShellFunction( |
| 76 | 'rg', |
| 77 | rgCommand.argv0, |
| 78 | rgCommand.rgPath, |
| 79 | ), |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // For regular ripgrep, use a simple alias target |
| 84 | const quotedPath = quote([rgCommand.rgPath]) |
| 85 | const quotedArgs = rgCommand.rgArgs.map(arg => quote([arg])) |
| 86 | const aliasTarget = |
| 87 | rgCommand.rgArgs.length > 0 |
| 88 | ? `${quotedPath} ${quotedArgs.join(' ')}` |
| 89 | : quotedPath |
| 90 | |
| 91 | return { type: 'alias', snippet: aliasTarget } |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * VCS directories to exclude from grep searches. Matches the list in |
no test coverage detected