* @private * @param {ClientConnection[]} clients clients * @param {StatsCompilation} stats stats * @param {boolean=} force force
(clients, stats, force)
| 3355 | * @param {boolean=} force force |
| 3356 | */ |
| 3357 | sendStats(clients, stats, force) { |
| 3358 | const shouldEmit = |
| 3359 | !force && |
| 3360 | stats && |
| 3361 | (!stats.errors || stats.errors.length === 0) && |
| 3362 | (!stats.warnings || stats.warnings.length === 0) && |
| 3363 | this.currentHash === stats.hash; |
| 3364 | |
| 3365 | if (shouldEmit) { |
| 3366 | this.sendMessage(clients, "still-ok"); |
| 3367 | |
| 3368 | return; |
| 3369 | } |
| 3370 | |
| 3371 | this.currentHash = stats.hash; |
| 3372 | this.sendMessage(clients, "hash", stats.hash); |
| 3373 | |
| 3374 | if ( |
| 3375 | /** @type {NonNullable<StatsCompilation["errors"]>} */ |
| 3376 | (stats.errors).length > 0 || |
| 3377 | /** @type {NonNullable<StatsCompilation["warnings"]>} */ |
| 3378 | (stats.warnings).length > 0 |
| 3379 | ) { |
| 3380 | const hasErrors = |
| 3381 | /** @type {NonNullable<StatsCompilation["errors"]>} */ |
| 3382 | (stats.errors).length > 0; |
| 3383 | |
| 3384 | if ( |
| 3385 | /** @type {NonNullable<StatsCompilation["warnings"]>} */ |
| 3386 | (stats.warnings).length > 0 |
| 3387 | ) { |
| 3388 | let params; |
| 3389 | |
| 3390 | if (hasErrors) { |
| 3391 | params = { preventReloading: true }; |
| 3392 | } |
| 3393 | |
| 3394 | this.sendMessage(clients, "warnings", stats.warnings, params); |
| 3395 | } |
| 3396 | |
| 3397 | if ( |
| 3398 | /** @type {NonNullable<StatsCompilation["errors"]>} */ (stats.errors) |
| 3399 | .length > 0 |
| 3400 | ) { |
| 3401 | this.sendMessage(clients, "errors", stats.errors); |
| 3402 | } |
| 3403 | } else { |
| 3404 | this.sendMessage(clients, "ok"); |
| 3405 | } |
| 3406 | } |
| 3407 | |
| 3408 | /** |
| 3409 | * @param {string | string[]} watchPath watch path |
no test coverage detected