Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw an error when activating a theme or plugin that doesn't exist #1391

Merged
merged 12 commits into from
May 16, 2024
Prev Previous commit
Always try to activate by name if path didn't work
  • Loading branch information
bgrgicak committed May 16, 2024
commit 68edf7f1241c6add5a2522f3215ba39b9a4c1e79
12 changes: 7 additions & 5 deletions packages/playground/blueprints/src/lib/steps/activate-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ export const activatePlugin: StepHandler<ActivatePluginStep> = async (
$response = false;
if (!is_dir($plugin_path)) {
$response = activate_plugin($plugin_path);
} else {
// A plugin name was provided instead of a path
}

// Activate plugin by name if activation by path wasn't successful
if ( null !== $response ) {
foreach ( ( glob( $plugin_path . '/*.php' ) ?: array() ) as $file ) {
$info = get_plugin_data( $file, false, false );
if ( ! empty( $info['Name'] ) ) {
Expand All @@ -58,13 +60,13 @@ export const activatePlugin: StepHandler<ActivatePluginStep> = async (
}
}

if ( false === $response ) {
throw new Exception( 'Plugin not found' );
if ( null === $response ) {
die('Plugin activated successfully');
} else if ( is_wp_error( $response ) ) {
throw new Exception( $response->get_error_message() );
}

die('Plugin activated successfully');
throw new Exception( 'Unable to activate plugin' );
`,
});
};
Loading