Skip to content

Commit 4bc269f

Browse files
committed
refactor: extract duplicate plugin warning into helper and improve wording
1 parent e78ce75 commit 4bc269f

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

packages/openapi-ts/src/config/plugins.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,16 @@ export function getPlugins({
149149

150150
const seenPlugins = new Set<string>();
151151

152+
const warnDuplicatePlugin = (name: string) =>
153+
console.warn(
154+
`⚙️ ${colors.yellow('Warning:')} Duplicate plugin ${colors.cyan(`"${name}"`)} detected. Only the last occurrence will take effect.`,
155+
);
156+
152157
const userPlugins = definedPlugins
153158
.map((plugin) => {
154159
if (typeof plugin === 'string') {
155160
if (seenPlugins.has(plugin)) {
156-
console.warn(
157-
`⚙️ ${colors.yellow('Warning:')} Duplicate plugin ${colors.cyan(`"${plugin}"`)} detected. The last configuration will be used.`,
158-
);
161+
warnDuplicatePlugin(plugin);
159162
}
160163
seenPlugins.add(plugin);
161164
return plugin;
@@ -165,9 +168,7 @@ export function getPlugins({
165168

166169
if (pluginName) {
167170
if (seenPlugins.has(pluginName)) {
168-
console.warn(
169-
`⚙️ ${colors.yellow('Warning:')} Duplicate plugin ${colors.cyan(`"${pluginName}"`)} detected. The last configuration will be used.`,
170-
);
171+
warnDuplicatePlugin(pluginName);
171172
}
172173
seenPlugins.add(pluginName);
173174

0 commit comments

Comments
 (0)