Skip to content

Commit

Permalink
Merge pull request #332 from wp-cli/fix/330-exclude-missing-plugin
Browse files Browse the repository at this point in the history
Avoid throwing error when excluding missing plugin
  • Loading branch information
schlessera authored Oct 17, 2022
2 parents 2981c34 + 3bf9330 commit c3f3f84
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 0 deletions.
10 changes: 10 additions & 0 deletions features/plugin-activate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,13 @@ Feature: Activate WordPress plugins
Success: Activated 1 of 1 plugins.
"""
And the return code should be 0

Scenario: Excluding a missing plugin should not throw an error
Given a WP install
And I run `wp plugin activate --all --exclude=missing-plugin`
Then STDERR should be empty
And STDOUT should contain:
"""
Success:
"""
And the return code should be 0
10 changes: 10 additions & 0 deletions features/plugin-deactivate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,13 @@ Feature: Deactivate WordPress plugins
Error: Please specify one or more plugins, or use --all.
"""
And STDOUT should be empty

Scenario: Excluding a missing plugin should not throw an error
Given a WP install
And I run `wp plugin deactivate --all --exclude=missing-plugin`
Then STDERR should be empty
And STDOUT should contain:
"""
Success:
"""
And the return code should be 0
10 changes: 10 additions & 0 deletions features/plugin-delete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@ Feature: Delete WordPress plugins
Success: No plugins deleted.
"""
And the return code should be 0

Scenario: Excluding a missing plugin should not throw an error
Given a WP install
And I run `wp plugin delete --all --exclude=missing-plugin`
Then STDERR should be empty
And STDOUT should contain:
"""
Success:
"""
And the return code should be 0
12 changes: 12 additions & 0 deletions features/plugin-uninstall.feature
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,15 @@ Feature: Uninstall a WordPress plugin
Success: No plugins uninstalled.
"""
And the return code should be 0



Scenario: Excluding a missing plugin should not throw an error
Given a WP install
And I run `wp plugin uninstall --all --exclude=missing-plugin`
Then STDERR should be empty
And STDOUT should contain:
"""
Success:
"""
And the return code should be 0
10 changes: 10 additions & 0 deletions features/plugin-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,13 @@ Feature: Update WordPress plugins
"""
Success:
"""

Scenario: Excluding a missing plugin should not throw an error
Given a WP install
And I run `wp plugin update --all --exclude=missing-plugin`
Then STDERR should be empty
And STDOUT should contain:
"""
Success:
"""
And the return code should be 0
12 changes: 12 additions & 0 deletions features/theme.feature
Original file line number Diff line number Diff line change
Expand Up @@ -673,3 +673,15 @@ Feature: Manage WordPress themes

When I try `wp theme is-active p2`
Then the return code should be 1

Scenario: Excluding a missing theme should not throw an error
Given a WP install
And I run `wp theme delete --all --force`
And I run `wp theme install p2 --version=1.5.5 --activate`
And I run `wp theme update --all --exclude=missing-theme`
Then STDERR should be empty
And STDOUT should contain:
"""
Success:
"""
And the return code should be 0
6 changes: 6 additions & 0 deletions src/WP_CLI/CommandWithUpgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,15 @@ protected function update_many( $args, $assoc_args ) {
foreach ( $exclude_items as $item ) {
if ( 'plugin' === $this->item_type ) {
$plugin = $this->fetcher->get( $item );
if ( ! $plugin ) {
continue;
}
unset( $items_to_update[ $plugin->file ] );
} elseif ( 'theme' === $this->item_type ) {
$theme_root = get_theme_root() . '/' . $item;
if ( ! is_dir( $theme_root ) ) {
continue;
}
unset( $items_to_update[ $theme_root ] );
}
}
Expand Down

0 comments on commit c3f3f84

Please sign in to comment.