MCPcopy Index your code
hub / github.com/SchemaStore/schemastore / assertCatalogJsonHasNoDuplicateNames

Function assertCatalogJsonHasNoDuplicateNames

cli.js:1293–1313  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1291}
1292
1293function assertCatalogJsonHasNoDuplicateNames() {
1294 /** @type {string[]} */
1295 const schemaNames = Catalog.schemas.map((entry) => entry.name)
1296 /** @type {string[]} */
1297
1298 for (const catalogEntry of Catalog.schemas) {
1299 if (
1300 schemaNames.indexOf(catalogEntry.name) !==
1301 schemaNames.lastIndexOf(catalogEntry.name)
1302 ) {
1303 const duplicateEntry =
1304 Catalog.schemas[schemaNames.lastIndexOf(catalogEntry.name)]
1305 printErrorAndExit(new Error(), [
1306 `Found two schema entries with duplicate "name" of "${catalogEntry.name}" in file "${CatalogFile}"`,
1307 `The first entry has url "${catalogEntry.url}"`,
1308 `The second entry has url "${duplicateEntry.url}"`,
1309 `Expected the "name" property of schema entries to be unique`,
1310 ])
1311 }
1312 }
1313}
1314
1315function assertCatalogJsonHasNoBadFields() {
1316 for (const catalogEntry of Catalog.schemas) {

Callers 1

taskCheckFunction · 0.85

Calls 1

printErrorAndExitFunction · 0.85

Tested by

no test coverage detected