Skip to content

Commit d54dec2

Browse files
authored
Merge pull request #300 from Nikschavan/299-skip-update-check
2 parents 82bdf8b + bbaf0fa commit d54dec2

File tree

6 files changed

+62
-2
lines changed

6 files changed

+62
-2
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"wp-cli/wp-cli": "^2.5.1"
2222
},
2323
"require-dev": {
24+
"wp-cli/cache-command": "^2.0",
2425
"wp-cli/entity-command": "^1.3 || ^2",
2526
"wp-cli/scaffold-command": "^1.2 || ^2",
2627
"wp-cli/wp-cli-tests": "^3.0.16"

features/plugin.feature

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,31 @@ Feature: Manage WordPress plugins
341341
| akismet | active | akismet/akismet.php |
342342
| wordpress-importer | inactive | wordpress-importer/wordpress-importer.php |
343343

344+
Scenario: Flag `--skip-update-check` skips update check when running `wp plugin list`
345+
Given a WP install
346+
347+
When I run `wp plugin install wordpress-importer --version=0.2`
348+
Then STDOUT should contain:
349+
"""
350+
Plugin installed successfully.
351+
"""
352+
353+
When I run `wp plugin list --fields=name,status,update --status=inactive`
354+
Then STDOUT should be a table containing rows:
355+
| name | status | update |
356+
| wordpress-importer | inactive | available |
357+
358+
When I run `wp transient delete update_plugins --network`
359+
Then STDOUT should be:
360+
"""
361+
Success: Transient deleted.
362+
"""
363+
364+
When I run `wp plugin list --fields=name,status,update --status=inactive --skip-update-check`
365+
Then STDOUT should be a table containing rows:
366+
| name | status | update |
367+
| wordpress-importer | inactive | none |
368+
344369
Scenario: Install a plugin when directory doesn't yet exist
345370
Given a WP install
346371

features/theme.feature

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,31 @@ Feature: Manage WordPress themes
178178
And STDOUT should be empty
179179
And the return code should be 0
180180
181+
Scenario: Flag `--skip-update-check` skips update check when running `wp theme list`
182+
Given a WP install
183+
184+
When I run `wp theme install astra --version=1.0.0`
185+
Then STDOUT should contain:
186+
"""
187+
Theme installed successfully.
188+
"""
189+
190+
When I run `wp theme list --fields=name,status,update`
191+
Then STDOUT should be a table containing rows:
192+
| name | status | update |
193+
| astra | inactive | available |
194+
195+
When I run `wp transient delete update_themes --network`
196+
Then STDOUT should be:
197+
"""
198+
Success: Transient deleted.
199+
"""
200+
201+
When I run `wp theme list --fields=name,status,update --skip-update-check`
202+
Then STDOUT should be a table containing rows:
203+
| name | status | update |
204+
| astra | inactive | none |
205+
181206
Scenario: Install a theme when the theme directory doesn't yet exist
182207
Given a WP install
183208

src/Plugin_Command.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,9 @@ public function delete( $args, $assoc_args = array() ) {
10831083
* - must-use
10841084
* ---
10851085
*
1086+
* [--skip-update-check]
1087+
* : If set, the plugin update check will be skipped.
1088+
*
10861089
* ## AVAILABLE FIELDS
10871090
*
10881091
* These fields will be displayed by default for each plugin:

src/Theme_Command.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,9 @@ public function delete( $args, $assoc_args ) {
832832
* - inactive
833833
* ---
834834
*
835+
* [--skip-update-check]
836+
* : If set, the theme update check will be skipped.
837+
*
835838
* ## AVAILABLE FIELDS
836839
*
837840
* These fields will be displayed by default for each theme:

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,11 @@ static function ( $result ) {
480480

481481
// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore -- Whitelisting to provide backward compatibility to classes possibly extending this class.
482482
protected function _list( $_, $assoc_args ) {
483-
// Force WordPress to check for updates
484-
call_user_func( $this->upgrade_refresh );
483+
484+
// Force WordPress to check for updates if `--skip-update-check` is not passed.
485+
if ( false === (bool) Utils\get_flag_value( $assoc_args, 'skip-update-check', false ) ) {
486+
call_user_func( $this->upgrade_refresh );
487+
}
485488

486489
$all_items = $this->get_all_items();
487490

0 commit comments

Comments
 (0)