Skip to content

Commit 6c45513

Browse files
Merge pull request #8 from runcommand/6-version-numbers
Recognize version numbers in `composer.json` files
2 parents 499ae93 + a6c7a9e commit 6c45513

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

command.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@
8989
}
9090
}
9191

92+
if ( empty( $version ) && file_exists( $path . '/composer.json' ) ) {
93+
$composer_obj = json_decode( file_get_contents( $path . '/composer.json' ) );
94+
if ( ! empty( $composer_obj->version ) ) {
95+
$version = '.' . trim( $composer_obj->version );
96+
}
97+
}
98+
9299
if ( 'zip' === $assoc_args['format'] ) {
93100
if ( is_null( $archive_file ) ) {
94101
$archive_file = dirname( $path ) . '/' . $archive_base . $version . '.zip';

features/dist-archive.feature

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,27 @@ Feature: Generate a distribution archive of a project
3737
"""
3838
And the hello-world.zip file should exist
3939
And the wp-content/plugins/hello-world.0.1.0.zip file should not exist
40+
41+
Scenario: Generate a ZIP archive using version number in composer.json
42+
Given an empty directory
43+
And a foo/.distignore file:
44+
"""
45+
.gitignore
46+
.distignore
47+
"""
48+
And a foo/composer.json file:
49+
"""
50+
{
51+
"name": "runcommand/profile",
52+
"description": "Quickly identify what's slow with WordPress.",
53+
"homepage": "https://runcommand.io/wp/profile/",
54+
"version": "0.2.0-alpha"
55+
}
56+
"""
57+
58+
When I run `wp dist-archive foo`
59+
Then STDOUT should be:
60+
"""
61+
Success: Created foo.0.2.0-alpha.zip
62+
"""
63+
And the foo.0.2.0-alpha.zip file should exist

0 commit comments

Comments
 (0)