* Extracts @Output() property names from a component .ts file using regex. * * Handles patterns: * - @Output() eventName = new EventEmitter (); * - @Output() eventName = new EventEmitter();
(componentFilePath: string)
| 190 | * - @Output() eventName = new EventEmitter(); |
| 191 | */ |
| 192 | function extractOutputs(componentFilePath: string): string[] { |
| 193 | const content = fs.readFileSync(componentFilePath, 'utf-8'); |
| 194 | const outputs: string[] = []; |
| 195 | |
| 196 | const outputRegex = /@Output\(\)\s+(\w+)\s*=\s*new\s+EventEmitter/g; |
| 197 | let match: RegExpExecArray | null; |
| 198 | |
| 199 | while ((match = outputRegex.exec(content)) !== null) { |
| 200 | const eventName = match[1]; |
| 201 | if (eventName && !outputs.includes(eventName)) { |
| 202 | outputs.push(eventName); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | return outputs.sort(); |
| 207 | } |
| 208 | |
| 209 | // ============================================ |
| 210 | // Task 1.3: MDX Properties/Events Table Parsing |