(commandText: string)
| 82 | } |
| 83 | |
| 84 | function cleanCommandText(commandText: string) { |
| 85 | if (!commandText) { |
| 86 | return ""; |
| 87 | } |
| 88 | const trimmed = commandText.trim(); |
| 89 | const shellMatch = trimmed.match( |
| 90 | /^(?:\/\S+\/)?(?:bash|zsh|sh|fish)(?:\.exe)?\s+-lc\s+(?:(['"])([\s\S]+)\1|([\s\S]+))$/, |
| 91 | ); |
| 92 | const inner = shellMatch ? (shellMatch[2] ?? shellMatch[3] ?? "") : trimmed; |
| 93 | const cdMatch = inner.match( |
| 94 | /^\s*cd\s+[^&;]+(?:\s*&&\s*|\s*;\s*)([\s\S]+)$/i, |
| 95 | ); |
| 96 | const stripped = cdMatch ? cdMatch[1] : inner; |
| 97 | return stripped.trim(); |
| 98 | } |
| 99 | |
| 100 | function tokenizeCommand(command: string) { |
| 101 | const tokens: string[] = []; |
no outgoing calls
no test coverage detected