Remove unnecessary package version reading of @wordpress/components (https://github.com/woocommerce/woocommerce-blocks/pull/1154)

* remove unnecessary package version reading of @wordpress/components

* comment out unused variable
This commit is contained in:
Darren Ethier 2019-11-11 13:09:09 -05:00 committed by GitHub
parent 8fe23415ba
commit 0ee090d16d
1 changed files with 11 additions and 20 deletions

View File

@ -75,26 +75,17 @@ class Bootstrap {
$this->container->register(
AssetDataRegistry::class,
function( Container $container ) {
$asset_api = $container->get( AssetApi::class );
$js_package = \json_decode(
// phpcs:disable WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
\file_get_contents(
$this->package->get_path( 'package.json' )
),
true
);
$woocommerce_components_version =
isset( $js_package['dependencies']['@woocommerce/components'] )
? $js_package['dependencies']['@woocommerce/components']
: 0;
$load_back_compat = '3.2.0' === $woocommerce_components_version
|| (
defined( 'WC_ADMIN_VERSION_NUMBER' )
&& version_compare( WC_ADMIN_VERSION_NUMBER, '0.19.0', '<=' )
);
return $load_back_compat
? new BackCompatAssetDataRegistry( $asset_api )
: new AssetDataRegistry( $asset_api );
$asset_api = $container->get( AssetApi::class );
// phpcs:disable Squiz . PHP . CommentedOutCode . Found
// @todo: this needs added back in once the @woocommerce/components
// package has been updated.
// $load_back_compat = defined( 'WC_ADMIN_VERSION_NUMBER' )
// && version_compare( WC_ADMIN_VERSION_NUMBER, '0.19.0', '<=' );
// return $load_back_compat
// ? new BackCompatAssetDataRegistry( $asset_api )
// : new AssetDataRegistry( $asset_api );
// phpcs:enable
return new BackCompatAssetDataRegistry( $asset_api );
}
);