| 131 | * @returns {(percentage: number) => string} bar renderer |
| 132 | */ |
| 133 | const createReportBar = (name, color) => { |
| 134 | const c = getColors(); |
| 135 | |
| 136 | return (percentage) => { |
| 137 | const w = Math.round(percentage * BAR_LENGTH); |
| 138 | const filled = BLOCK_CHAR.repeat(w); |
| 139 | const empty = BLOCK_CHAR.repeat(BAR_LENGTH - w); |
| 140 | const colorFn = |
| 141 | color in c ? c[/** @type {keyof Colors} */ (color)] : c.green; |
| 142 | |
| 143 | return `${[BULLET_ICON, name, filled].map(colorFn).join(" ")}${c.white(empty)}`; |
| 144 | }; |
| 145 | }; |
| 146 | |
| 147 | /** @typedef {Required<Exclude<NonNullable<ProgressPluginOptions["progressBar"]>, boolean>>} ProgressBarOptions */ |
| 148 | |