MCPcopy
hub / github.com/homebridge/homebridge / coerceIdentifierList

Method coerceIdentifierList

src/pluginManager.ts:122–131  ·  view source on GitHub ↗

* Coerce an options value to a `PluginIdentifier[]` or undefined. * Used for `activePlugins` and `disabledPlugins`: a stray string would * otherwise pass through and turn later `.includes(pluginIdentifier)` * calls into substring matches. Emits a warning so the typo isn't * silently swal

(value: unknown, fieldName: string)

Source from the content-addressed store, hash-verified

120 * full PluginManager.
121 */
122 public static coerceIdentifierList(value: unknown, fieldName: string): PluginIdentifier[] | undefined {
123 if (value === undefined || value === null) {
124 return undefined
125 }
126 if (Array.isArray(value)) {
127 return value as PluginIdentifier[]
128 }
129 log.warn(`config.${fieldName} must be an array of plugin identifiers; got ${typeof value} — ignoring this setting.`)
130 return undefined
131 }
132
133 public static isQualifiedPluginIdentifier(identifier: string): boolean {
134 return PluginManager.PLUGIN_IDENTIFIER_PATTERN.test(identifier)

Callers 1

constructorMethod · 0.80

Calls 1

warnMethod · 0.80

Tested by

no test coverage detected