diff --git a/php/commands/src/CLI_Command.php b/php/commands/src/CLI_Command.php index a4f5f6071..433821cdc 100644 --- a/php/commands/src/CLI_Command.php +++ b/php/commands/src/CLI_Command.php @@ -322,23 +322,25 @@ public function update( $_, $assoc_args ) { EE::error( 'The downloaded PHAR is broken, try running ee cli update again.' ); } EE::log( 'New version works. Proceeding to replace.' ); + if ( Utils\get_flag_value( $assoc_args, 'nightly' ) ) { + $updated_version = 'the latest nightly release'; + } elseif ( Utils\get_flag_value( $assoc_args, 'stable' ) ) { + $updated_version = 'the latest stable release'; + } else { + $updated_version = $newest['version']; + } + $is_quiet = ! empty( EE::get_runner()->config['quiet'] ); $mode = fileperms( $old_phar ) & 511; if ( false === chmod( $temp, $mode ) ) { EE::error( sprintf( 'Cannot chmod %s.', $temp ) ); } - class_exists( '\cli\Streams' ); // This autoloads \cli\Streams - after we move the file we no longer have access to this class. - class_exists( '\cli\Colors' ); // This autoloads \cli\Colors if ( false === rename( $temp, $old_phar ) ) { EE::error( sprintf( 'Cannot move %s to %s', $temp, $old_phar ) ); } - if ( Utils\get_flag_value( $assoc_args, 'nightly' ) ) { - $updated_version = 'the latest nightly release'; - } elseif ( Utils\get_flag_value( $assoc_args, 'stable' ) ) { - $updated_version = 'the latest stable release'; - } else { - $updated_version = $newest['version']; + // The running Phar has been replaced; avoid logger/color autoloads from it. + if ( ! $is_quiet ) { + fwrite( STDOUT, sprintf( 'Success: Updated EE to %s.' . PHP_EOL, $updated_version ) ); } - EE::success( sprintf( 'Updated EE to %s.', $updated_version ) ); } /**