( watchPluginKeys: WatchPluginKeysMap, plugin: WatchPlugin, globalConfig: Config.GlobalConfig, )
| 472 | } |
| 473 | |
| 474 | const checkForConflicts = ( |
| 475 | watchPluginKeys: WatchPluginKeysMap, |
| 476 | plugin: WatchPlugin, |
| 477 | globalConfig: Config.GlobalConfig, |
| 478 | ) => { |
| 479 | const key = getPluginKey(plugin, globalConfig); |
| 480 | if (!key) { |
| 481 | return; |
| 482 | } |
| 483 | |
| 484 | const conflictor = watchPluginKeys.get(key); |
| 485 | if (!conflictor || conflictor.overwritable) { |
| 486 | watchPluginKeys.set(key, { |
| 487 | overwritable: false, |
| 488 | plugin, |
| 489 | }); |
| 490 | return; |
| 491 | } |
| 492 | |
| 493 | let error; |
| 494 | if (conflictor.forbiddenOverwriteMessage) { |
| 495 | error = ` |
| 496 | Watch plugin ${chalk.bold.red( |
| 497 | getPluginIdentifier(plugin), |
| 498 | )} attempted to register key ${chalk.bold.red(`<${key}>`)}, |
| 499 | that is reserved internally for ${chalk.bold.red( |
| 500 | conflictor.forbiddenOverwriteMessage, |
| 501 | )}. |
| 502 | Please change the configuration key for this plugin.`.trim(); |
| 503 | } else { |
| 504 | const plugins = [conflictor.plugin, plugin] |
| 505 | .map(p => chalk.bold.red(getPluginIdentifier(p))) |
| 506 | .join(' and '); |
| 507 | error = ` |
| 508 | Watch plugins ${plugins} both attempted to register key ${chalk.bold.red( |
| 509 | `<${key}>`, |
| 510 | )}. |
| 511 | Please change the key configuration for one of the conflicting plugins to avoid overlap.`.trim(); |
| 512 | } |
| 513 | |
| 514 | throw new ValidationError('Watch plugin configuration error', error); |
| 515 | }; |
| 516 | |
| 517 | const getPluginIdentifier = (plugin: WatchPlugin) => |
| 518 | // This breaks as `displayName` is not defined as a static, but since |
no test coverage detected