(startIndex: number)
| 1292 | const parsedList: Array<{ path: string; content: string; parsed: { name?: string; workflow?: unknown[] } | null }> = []; |
| 1293 | |
| 1294 | const parseBatch = (startIndex: number) => { |
| 1295 | try { |
| 1296 | const endIndex = Math.min(startIndex + BATCH_SIZE, contents.length); |
| 1297 | const batch = contents.slice(startIndex, endIndex); |
| 1298 | |
| 1299 | // Parse this batch |
| 1300 | batch.forEach((c) => { |
| 1301 | try { |
| 1302 | parsedList.push({ |
| 1303 | path: c.path, |
| 1304 | content: c.content, |
| 1305 | parsed: yamlLib.load(c.content) as { name?: string; workflow?: unknown[] } | null, |
| 1306 | }); |
| 1307 | } catch (e) { |
| 1308 | console.warn(`Failed to parse ${c.path}:`, e); |
| 1309 | parsedList.push({ |
| 1310 | path: c.path, |
| 1311 | content: c.content, |
| 1312 | parsed: null, |
| 1313 | }); |
| 1314 | } |
| 1315 | }); |
| 1316 | |
| 1317 | // Continue with next batch or finish |
| 1318 | if (endIndex < contents.length) { |
| 1319 | if (typeof requestIdleCallback !== 'undefined') { |
| 1320 | requestIdleCallback(() => parseBatch(endIndex), { timeout: 100 }); |
| 1321 | } else { |
| 1322 | setTimeout(() => parseBatch(endIndex), 0); |
| 1323 | } |
| 1324 | } else { |
| 1325 | // All parsed, now find main candidate and process |
| 1326 | findMainAndProcess(); |
| 1327 | } |
| 1328 | } catch (e) { |
| 1329 | console.error('Error in parseBatch:', e); |
| 1330 | // Still try to process what we have |
| 1331 | if (parsedList.length > 0) { |
| 1332 | findMainAndProcess(); |
| 1333 | } |
| 1334 | } |
| 1335 | }; |
| 1336 | |
| 1337 | const findMainAndProcess = () => { |
| 1338 | try { |
no test coverage detected