Skip to content

Commit

Permalink
Remove dependency on WP_CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Oct 7, 2013
1 parent da3555c commit 2e1b928
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions class-wordpress-readme-parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ function __construct( $args = array() ) {
$readme_txt_rest = $matches[4];
$this->metadata = array_fill_keys( array( 'Contributors', 'Tags', 'Requires at least', 'Tested up to', 'Stable tag', 'License', 'License URI' ), null );
foreach ( explode( "\n", $matches[2] ) as $metadatum ) {
preg_match( '/^(.+?):\s+(.+)$/', $metadatum, $metadataum_matches ) || \WP_CLI::error( "Parse error in $metadatum" );
if ( ! preg_match( '/^(.+?):\s+(.+)$/', $metadatum, $metadataum_matches ) ) {
throw new \Exception( "Parse error in $metadatum" );
}
list( $name, $value ) = array_slice( $metadataum_matches, 1, 2 );
$this->metadata[$name] = $value;
}
Expand Down Expand Up @@ -92,7 +94,9 @@ function to_markdown( $params = array() ) {
'Screenshots' => function ( $body ) {
$body = trim( $body );
$new_body = '';
preg_match_all( '/^\d+\. (.+?)$/m', $body, $screenshot_matches, PREG_SET_ORDER ) || \WP_CLI::error( 'Malformed screenshot section' );
if ( ! preg_match_all( '/^\d+\. (.+?)$/m', $body, $screenshot_matches, PREG_SET_ORDER ) ) {
throw new Exception( 'Malformed screenshot section' );
}
foreach ( $screenshot_matches as $i => $screenshot_match ) {
$img_extensions = array( 'jpg', 'gif', 'png' );
foreach ( $img_extensions as $ext ) {
Expand Down

0 comments on commit 2e1b928

Please sign in to comment.