Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib/import-export/export/exporters/default-exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export class DefaultExporter extends EventEmitter implements Exporter {

if ( stderr ) {
console.error( `Could not get information about plugins: ${ stderr }` );
return [];
}

return JSON.parse( stdout );
Expand All @@ -279,6 +280,7 @@ export class DefaultExporter extends EventEmitter implements Exporter {

if ( stderr ) {
console.error( `Could not get information about themes: ${ stderr }` );
return [];
}

return JSON.parse( stdout );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,26 @@ describe( 'DefaultExporter', () => {
const canHandle = await exporter.canHandle();
expect( canHandle ).toBe( false );
} );

it( 'should not fail when can not get plugin or theme details', async () => {
( SiteServer.get as jest.Mock ).mockReturnValue( {
details: { path: '/path/to/site' },
executeWpCliCommand: jest.fn( function ( command: string ) {
switch ( true ) {
case /plugin list/.test( command ):
case /theme list/.test( command ):
return { stdout: '<a><br/>some html</ap>', stderr: 'Error' };
default:
return { stderr: null };
}
} ),
} );

const exporter = new DefaultExporter( mockOptions );
await exporter.export();

expect( mockArchiver.file ).toHaveBeenCalledWith( '/tmp/studio_export_123/meta.json', {
name: 'meta.json',
} );
} );
} );