woocommerce/plugins/woocommerce-admin/bin/update-version.php

37 lines
1.1 KiB
PHP
Raw Normal View History

<?php
/**
* Updates PHP versions to match those in package.json before start or build.
*
* @package WooCommerce Admin
*/
$package_json = file_get_contents( 'package.json' );
$package = json_decode( $package_json );
2019-08-15 02:24:34 +00:00
function replace_version( $filename, $package_json ) {
2019-08-15 02:25:18 +00:00
$lines = array();
$file = file( $filename );
2019-08-15 02:24:34 +00:00
foreach ( $file as $line ) {
if ( stripos( $line, ' * Version: ' ) !== false ) {
$line = " * Version: {$package_json->version}\n";
}
if ( stripos( $line, ">define( 'WC_ADMIN_VERSION_NUMBER'," ) !== false ) {
$line = "\t\t\$this->define( 'WC_ADMIN_VERSION_NUMBER', '{$package_json->version}' );\n";
}
if ( stripos( $line, "const VERSION =" ) !== false ) {
$line = "\tconst VERSION = '{$package_json->version}';\n";
}
if ( stripos( $line, 'Stable tag: ' ) !== false ) {
$line = "Stable tag: {$package_json->version}\n";
}
2019-08-15 02:24:34 +00:00
$lines[] = $line;
}
2019-08-15 02:24:34 +00:00
file_put_contents( $filename, $lines );
}
2019-08-15 02:24:34 +00:00
replace_version( 'woocommerce-admin.php', $package );
replace_version( 'src/FeaturePlugin.php', $package );
replace_version( 'src/Package.php', $package );
replace_version( 'readme.txt', $package );