build(aio): fix empty docplaster processing

This commit is contained in:
Peter Bacon Darwin 2017-04-01 00:07:14 +01:00 committed by Alex Rickabaugh
parent 5fbb0d050c
commit 3e793f079d
2 changed files with 15 additions and 2 deletions

View File

@ -56,7 +56,9 @@ function regionParserImpl(contents, fileType) {
`Tried to open a region, named "${regionName}", that is already open`, index); `Tried to open a region, named "${regionName}", that is already open`, index);
} }
region.open = true; region.open = true;
region.lines.push(plaster); if (plaster) {
region.lines.push(plaster);
}
} else { } else {
regionMap[regionName] = {lines: [], open: true}; regionMap[regionName] = {lines: [], open: true};
} }
@ -86,7 +88,8 @@ function regionParserImpl(contents, fileType) {
// doc plaster processing // doc plaster processing
} else if (updatePlaster) { } else if (updatePlaster) {
plaster = regionMatcher.createPlasterComment(updatePlaster[1].trim()); const plasterString = updatePlaster[1].trim();
plaster = plasterString ? regionMatcher.createPlasterComment(plasterString) : '';
// simple line of content processing // simple line of content processing
} else { } else {

View File

@ -153,6 +153,16 @@ describe('regionParser service', () => {
expect(output.regions['A']).toEqual(t('jkl', '/* ... elided ... */', 'pqr')); expect(output.regions['A']).toEqual(t('jkl', '/* ... elided ... */', 'pqr'));
}); });
it('should remove the plaster altogether if the current plaster string is ""', () => {
const output = regionParser(
t('/* #docregion */', 'abc', '/* #enddocregion */', 'def', '/* #docregion */', 'ghi',
'/* #enddocregion */', '/* #docplaster */', '/* #docregion A */', 'jkl',
'/* #enddocregion A */', 'mno', '/* #docregion A */', 'pqr', '/* #enddocregion A */'),
'test-type');
expect(output.regions['']).toEqual(t('abc', '/* . . . */', 'ghi'));
expect(output.regions['A']).toEqual(t('jkl', 'pqr'));
});
it('should parse multiple region names separated by commas', () => { it('should parse multiple region names separated by commas', () => {
const output = regionParser( const output = regionParser(
t('/* #docregion , A, B */', 'abc', '/* #enddocregion B */', '/* #docregion C */', 'xyz', t('/* #docregion , A, B */', 'abc', '/* #enddocregion B */', '/* #docregion C */', 'xyz',