feat(bgm): support role= on code block info strings
Parse role.type#id from the fence info string and merge it into each parsed object, erroring on conflicts with the content. id on the info string can't combine with $variants. Auto-named blocks now hash their content instead of the info string, so identical blocks dedupe.
This commit is contained in:
@@ -86,4 +86,18 @@ describe('collectPackages', () => {
|
||||
defMap.defs.set(tokensKey.replace('tokens.yaml', 'dup.yaml'), [tokens[0]!]);
|
||||
expect(() => collectPackages(defMap, fixtureRoot)).toThrow(/Duplicate part/);
|
||||
});
|
||||
|
||||
it('throws when an info-string id combines with $variants', () => {
|
||||
const defMap = loadDefs('', fixtureRoot);
|
||||
// A part whose `id` comes from $variants rows, but with an info-string id.
|
||||
const tokensKey = [...defMap.defs.keys()].find((k) => k.endsWith('parts/tokens.yaml'))!;
|
||||
const tokens = defMap.defs.get(tokensKey)!;
|
||||
const variant = {
|
||||
...tokens[0]!,
|
||||
value: { ...tokens[0]!.value, id: undefined, $variants: './parts/seats.csv' },
|
||||
role: { role: 'part', type: 'token', id: 'wood' },
|
||||
};
|
||||
defMap.defs.set(tokensKey.replace('tokens.yaml', 'dup.yaml'), [variant]);
|
||||
expect(() => collectPackages(defMap, fixtureRoot)).toThrow(/can't combine with \$variants/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user