Skip to content

Commit

Permalink
fix(plugin-pages): do not throw on empty page list
Browse files Browse the repository at this point in the history
Closes #165
  • Loading branch information
GerkinDev committed Apr 7, 2023
1 parent 1523cfd commit 4b2d5ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/plugin-pages/src/options/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export const buildOptions = ( plugin: PagesPlugin ) => OptionGroup.factory<IPlug
validate: v => {
if( v ){
assert( isArray( v ), 'Pages should be an array' );
if( !v.length ){
return;
}
v.forEach( ( p, i ): asserts p is IRootPageNode => miscUtils.catchWrap(
() => checkRootPage( plugin, p, [] ),
wrapPageError( [], i ) ) );
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-pages/src/options/options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ beforeEach( () => {
} );

describe( 'Pages', () => {
it( 'should not throw if empty pages list', () => expect( () => options.setValue( { pages: [] as IRootPageNode[] } ) )
.not.toThrow( 'Every root pages should set `moduleRoot` to true, or none' ) );
it( 'should throw if inconsistent "moduleRoot" option given', () => expect( () => options.setValue( { pages: [
{ name: 'A', moduleRoot: true },
{ name: 'B' },
Expand Down

0 comments on commit 4b2d5ba

Please sign in to comment.