UNPKG

@netlify/config

Version:
21 lines (16 loc) 874 B
import { throwUserError } from '../error.js' // Validate that plugin are configured only once per origin // (`netlify.toml` or UI). // Exception: context-specific configuration since we allow context-specific // overrides. This does not validate them since contexts have not been merged // yet. export const validateIdenticalPlugins = function ({ plugins = [] }) { plugins.filter(hasIdenticalPlugin).forEach(throwIndenticalPlugin) } const hasIdenticalPlugin = function ({ package: packageName, origin }, index, plugins) { return plugins.slice(index + 1).some((pluginA) => packageName === pluginA.package && origin === pluginA.origin) } const throwIndenticalPlugin = function ({ package: packageName, origin }) { throwUserError(`Plugin "${packageName}" must not be specified twice in ${ORIGINS[origin]}`) } const ORIGINS = { config: 'netlify.toml', ui: 'the app' }