Skip to content

Commit 1d8e73a

Browse files
committed
Include bundled command assets directories in the Phar
1 parent 4bc3ca0 commit 1d8e73a

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎features/make-phar.feature‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,13 @@ Feature: Check `utils/make-phar.php` output
6666
"""
6767
SHA-512
6868
"""
69+
70+
Scenario: Bundled command assets are included in the Phar
71+
Given an empty directory
72+
And a new Phar with the same version
73+
74+
When I run `php -r '$phar = new Phar( "{PHAR_PATH}" ); echo isset( $phar["vendor/wp-cli/i18n-command/assets/block-i18n.json"] ) && isset( $phar["vendor/wp-cli/i18n-command/assets/theme-i18n.json"] ) ? "present" : "missing";'`
75+
Then STDOUT should be:
76+
"""
77+
present
78+
"""

‎utils/make-phar.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ function get_composer_versions( $current_version ) {
275275
->in( WP_CLI_ROOT . '/templates' )
276276
->in( WP_CLI_VENDOR_DIR . '/wp-cli/*-command/templates' );
277277

278+
if ( 'cli' !== BUILD ) {
279+
$asset_dirs = glob( WP_CLI_VENDOR_DIR . '/wp-cli/*-command/assets', GLOB_ONLYDIR );
280+
if ( ! empty( $asset_dirs ) ) {
281+
$finder->in( $asset_dirs );
282+
}
283+
}
284+
278285
foreach ( $finder as $file ) {
279286
add_file( $phar, $file );
280287
}

0 commit comments

Comments
 (0)