Skip to content

Commit 1fe271c

Browse files
Warn on delete failure, instead of hard exiting (#376)
* Warn on delete failure, instead of hard exiting * Add tests for e166709 * Newline at the end of the file Co-authored-by: Pascal Birchler <pascalb@google.com> --------- Co-authored-by: Pascal Birchler <pascalb@google.com>
1 parent 17b1654 commit 1fe271c

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

features/plugin-delete.feature

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,32 @@ Feature: Delete WordPress plugins
5757
Success:
5858
"""
5959
And the return code should be 0
60+
61+
Scenario: Reports a failure for a plugin that can't be deleted
62+
Given a WP install
63+
64+
When I run `chmod -w wp-content/plugins/akismet`
65+
And I try `wp plugin delete akismet`
66+
Then STDERR should contain:
67+
"""
68+
Warning: The 'akismet' plugin could not be deleted.
69+
"""
70+
And STDERR should contain:
71+
"""
72+
Error: No plugins deleted.
73+
"""
74+
Then STDOUT should not contain:
75+
"""
76+
Success:
77+
"""
78+
79+
When I run `chmod +w wp-content/plugins/akismet`
80+
And I run `wp plugin delete akismet`
81+
Then STDERR should not contain:
82+
"""
83+
Error:
84+
"""
85+
Then STDOUT should contain:
86+
"""
87+
Success:
88+
"""

src/Plugin_Command.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,7 @@ public function delete( $args, $assoc_args = array() ) {
11131113
WP_CLI::log( "Deleted '{$plugin->name}' plugin." );
11141114
++$successes;
11151115
} else {
1116+
WP_CLI::warning( "The '{$plugin->name}' plugin could not be deleted." );
11161117
++$errors;
11171118
}
11181119
}
@@ -1297,6 +1298,6 @@ private function delete_plugin( $plugin ) {
12971298
$command = 'rm -rf ';
12981299
}
12991300

1300-
return ! WP_CLI::launch( $command . escapeshellarg( $path ) );
1301+
return ! WP_CLI::launch( $command . escapeshellarg( $path ), false );
13011302
}
13021303
}

0 commit comments

Comments
 (0)