Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions php/commands/src/CLI_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}

/**
Expand Down
Loading