Skip to content

Commit

Permalink
Skip including Gutenberg in summary if there is another plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
delawski committed Jul 30, 2021
1 parent a3f8c80 commit 84fcf86
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions assets/src/utils/sources/summarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export default function summarizeSources( raw ) {

if ( sources[ SOURCE_TYPE_PLUGIN ] ) {
result[ SOURCE_TYPE_PLUGIN ] = sources[ SOURCE_TYPE_PLUGIN ];

// Skip including Gutenberg in the summary if there is another plugin, since Gutenberg is like core.
if ( result[ SOURCE_TYPE_PLUGIN ].length > 1 && result[ SOURCE_TYPE_PLUGIN ].includes( 'gutenberg' ) ) {
result[ SOURCE_TYPE_PLUGIN ] = result[ SOURCE_TYPE_PLUGIN ].filter( ( plugin ) => plugin !== 'gutenberg' );
}
}
if ( sources[ SOURCE_TYPE_MU_PLUGIN ] ) {
result[ SOURCE_TYPE_MU_PLUGIN ] = sources[ SOURCE_TYPE_MU_PLUGIN ];
Expand Down
38 changes: 38 additions & 0 deletions assets/src/utils/sources/test/summarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,42 @@ describe( 'summarizeSources', () => {
[ SOURCE_TYPE_THEME ]: [ 'baz' ],
} );
} );

it( 'returns Gutenberg if there is no other plugin', () => {
const result = summarizeSources( [
{
type: 'plugin',
name: 'gutenberg',
},
{
type: 'theme',
name: 'baz',
},
] );
expect( result ).toStrictEqual( {
[ SOURCE_TYPE_PLUGIN ]: [ 'gutenberg' ],
[ SOURCE_TYPE_THEME ]: [ 'baz' ],
} );
} );

it( 'does not return Gutenberg if there is another plugin', () => {
const result = summarizeSources( [
{
type: 'plugin',
name: 'foo',
},
{
type: 'plugin',
name: 'gutenberg',
},
{
type: 'theme',
name: 'baz',
},
] );
expect( result ).toStrictEqual( {
[ SOURCE_TYPE_PLUGIN ]: [ 'foo' ],
[ SOURCE_TYPE_THEME ]: [ 'baz' ],
} );
} );
} );

0 comments on commit 84fcf86

Please sign in to comment.