Skip to content

Commit

Permalink
Merge pull request #2537 from wp-cli/1564-composer-install-verbosity
Browse files Browse the repository at this point in the history
Make `wp package install` more verbose
  • Loading branch information
danielbachhuber committed Mar 7, 2016
2 parents 8af196a + c8e580a commit c6272b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 13 additions & 1 deletion php/WP_CLI/ComposerIO.php
Expand Up @@ -21,7 +21,19 @@ public function isVerbose() {
* {@inheritDoc}
*/
public function write( $messages, $newline = true ) {
WP_CLI::log( " - " . strip_tags( $messages ) );
self::output_clean_message( $messages );
}

/**
* {@inheritDoc}
*/
public function writeError( $messages, $newline = true ) {
self::output_clean_message( $messages );
}

private static function output_clean_message( $message ) {
$message = preg_replace( '#<(https?)([^>]+)>#', '$1$2', $message );
WP_CLI::log( strip_tags( trim( $message ) ) );
}

}
4 changes: 3 additions & 1 deletion php/commands/package.php
Expand Up @@ -108,17 +108,19 @@ public function install( $args, $assoc_args ) {

// Try running the installer, but revert composer.json if failed
WP_CLI::log( 'Using Composer to install the package...' );
WP_CLI::log( '---' );
try {
$res = $install->run();
} catch ( Exception $e ) {
WP_CLI::warning( $e->getMessage() );
}
WP_CLI::log( '---' );

if ( 0 === $res ) {
WP_CLI::success( "Package installed successfully." );
} else {
file_put_contents( $composer_json_obj->getPath(), $composer_backup );
WP_CLI::error( "Package installation failed. Reverted composer.json" );
WP_CLI::error( "Package installation failed (Composer return code {$res}). Reverted composer.json" );
}
}

Expand Down

0 comments on commit c6272b9

Please sign in to comment.