* Print information for a process * Used in multiple-run * @param {string | null} process * @returns {string}
(process)
| 49 | * @returns {string} |
| 50 | */ |
| 51 | process(process) { |
| 52 | if (process === null) return (outputProcess = '') |
| 53 | if (process) { |
| 54 | // Handle objects by converting to empty string or extracting properties |
| 55 | let processValue = process |
| 56 | if (typeof process === 'object') { |
| 57 | // If it's an object, try to extract a numeric value or use empty string |
| 58 | processValue = process.id || process.index || process.worker || '' |
| 59 | } |
| 60 | |
| 61 | // Check if this is a run-multiple process (contains : or .) |
| 62 | // Format: "1.runName:browserName" from run-multiple |
| 63 | if (String(processValue).includes(':') || (String(processValue).includes('.') && String(processValue).split('.').length > 1)) { |
| 64 | // Keep original format for run-multiple |
| 65 | outputProcess = colors.cyan.bold(`[${processValue}]`) |
| 66 | } else { |
| 67 | // Standard worker format for run-workers |
| 68 | const processNum = parseInt(processValue, 10) |
| 69 | const processStr = !isNaN(processNum) ? String(processNum).padStart(2, '0') : String(processValue).padStart(2, '0') |
| 70 | |
| 71 | // Assign different colors to different workers for better identification |
| 72 | const workerColors = [ |
| 73 | colors.cyan, // Worker 01 - Cyan |
| 74 | colors.magenta, // Worker 02 - Magenta |
| 75 | colors.green, // Worker 03 - Green |
| 76 | colors.yellow, // Worker 04 - Yellow |
| 77 | colors.blue, // Worker 05 - Blue |
| 78 | colors.red, // Worker 06 - Red |
| 79 | colors.white, // Worker 07 - White |
| 80 | colors.gray, // Worker 08 - Gray |
| 81 | ] |
| 82 | const workerIndex = !isNaN(processNum) ? processNum - 1 : -1 |
| 83 | const colorFn = workerIndex >= 0 && workerColors[workerIndex % workerColors.length] ? workerColors[workerIndex % workerColors.length] : colors.cyan |
| 84 | outputProcess = colorFn.bold(`[Worker ${processStr}]`) |
| 85 | } |
| 86 | } |
| 87 | return outputProcess |
| 88 | }, |
| 89 | |
| 90 | /** |
| 91 | * Print information in --debug mode |