Skip to content

Commit e5cd3a5

Browse files
committed
Add skip-update-check
1 parent eacf4ee commit e5cd3a5

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

src/Package_Command.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,9 @@ public function path( $args ) {
533533
* - yaml
534534
* ---
535535
*
536+
* [--skip-update-check]
537+
* : Skip checking for updates. This is faster and avoids authentication issues with GitHub or Composer repositories.
538+
*
536539
* ## AVAILABLE FIELDS
537540
*
538541
* These fields will be displayed by default for each package:
@@ -572,7 +575,8 @@ public function get( $args, $assoc_args ) {
572575
WP_CLI::error( sprintf( "Package '%s' is not installed.", $package_name ) );
573576
}
574577

575-
$composer = $this->get_composer();
578+
$skip_update_check = Utils\get_flag_value( $assoc_args, 'skip-update-check', false );
579+
$composer = $this->get_composer();
576580

577581
$package_output = [];
578582
$package_output['name'] = $package->getPrettyName();
@@ -582,16 +586,18 @@ public function get( $args, $assoc_args ) {
582586
$update = 'none';
583587
$update_version = '';
584588

585-
try {
586-
$latest = $this->find_latest_package( $package, $composer, null );
587-
if ( $latest && $latest->getFullPrettyVersion() !== $package->getFullPrettyVersion() ) {
588-
$update = 'available';
589-
$update_version = $latest->getPrettyVersion();
589+
if ( ! $skip_update_check ) {
590+
try {
591+
$latest = $this->find_latest_package( $package, $composer, null );
592+
if ( $latest && $latest->getFullPrettyVersion() !== $package->getFullPrettyVersion() ) {
593+
$update = 'available';
594+
$update_version = $latest->getPrettyVersion();
595+
}
596+
} catch ( Exception $e ) {
597+
WP_CLI::warning( $e->getMessage() );
598+
$update = 'error';
599+
$update_version = $update;
590600
}
591-
} catch ( Exception $e ) {
592-
WP_CLI::warning( $e->getMessage() );
593-
$update = 'error';
594-
$update_version = $update;
595601
}
596602

597603
$package_output['update'] = $update;

0 commit comments

Comments
 (0)