|
1 | 1 | import type { BaseExtractor, DependencyInfo, OffsetRange, WorkspaceCatalogExtractor, WorkspaceCatalogInfo, YamlNode } from '#types/extractor' |
2 | 2 | import type { Pair, Scalar, YAMLMap } from 'yaml' |
| 3 | +import { normalizeCatalogName } from '#utils/dependency' |
3 | 4 | import { isMap, isPair, isScalar, parseDocument } from 'yaml' |
4 | 5 |
|
5 | 6 | const CATALOG_SECTION = 'catalog' |
@@ -48,7 +49,7 @@ export class YamlExtractor implements WorkspaceCatalogExtractor, BaseExtractor<Y |
48 | 49 |
|
49 | 50 | #traverseCatalogs(root: YAMLMap, callback: CatalogEntryVisitor): boolean { |
50 | 51 | const catalog = root.items.find((i) => isScalar(i.key) && i.key.value === CATALOG_SECTION) |
51 | | - if (this.#traverseCatalog(catalog, { category: 'catalog' }, callback)) |
| 52 | + if (this.#traverseCatalog(catalog, { category: 'catalog', categoryName: '' }, callback)) |
52 | 53 | return true |
53 | 54 |
|
54 | 55 | const catalogs = root.items.find((i) => isScalar(i.key) && i.key.value === CATALOGS_SECTION) |
@@ -92,7 +93,7 @@ export class YamlExtractor implements WorkspaceCatalogExtractor, BaseExtractor<Y |
92 | 93 | const catalogs: Record<string, Record<string, string>> = {} |
93 | 94 |
|
94 | 95 | for (const dependency of dependencies) { |
95 | | - const categoryName = dependency.category === 'catalog' ? 'default' : dependency.categoryName || 'default' |
| 96 | + const categoryName = normalizeCatalogName(dependency.categoryName!) |
96 | 97 | catalogs[categoryName] ??= {} |
97 | 98 | catalogs[categoryName][dependency.rawName] = dependency.rawSpec |
98 | 99 | } |
|
0 commit comments