Skip to content

Commit ce62de9

Browse files
Merge pull request #2 from runcommand/include-version
Include the version in the archive file when found in plugin header
2 parents db15ad5 + a792f63 commit ce62de9

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

command.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,17 @@
6868
$ignored_files[] = $archive_base . '/' . $file;
6969
}
7070

71+
$version = '';
72+
foreach( glob( $path . '/*.php' ) as $php_file ) {
73+
$contents = file_get_contents( $php_file, false, null, 0, 5000 );
74+
if ( preg_match( '#\* Version:(.+)#', $contents, $matches ) ) {
75+
$version = '.' . trim( $matches[1] );
76+
break;
77+
}
78+
}
79+
7180
if ( 'zip' === $assoc_args['format'] ) {
72-
$archive_file = $archive_base . '.zip';
81+
$archive_file = $archive_base . $version . '.zip';
7382
$excludes = implode( ' --exclude ', $ignored_files );
7483
if ( ! empty( $excludes ) ) {
7584
$excludes = ' --exclude ' . $excludes;

features/dist-archive.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ Feature: Generate a distribution archive of a project
1010
And the wp-content/plugins/hello-world/bin directory should exist
1111

1212
When I run `wp dist-archive wp-content/plugins/hello-world`
13-
Then the wp-content/plugins/hello-world.zip file should exist
13+
And the wp-content/plugins/hello-world.0.1.0.zip file should exist
1414

1515
When I run `wp plugin delete hello-world`
1616
Then the wp-content/plugins/hello-world directory should not exist
1717

18-
When I run `wp plugin install wp-content/plugins/hello-world.zip`
18+
When I run `wp plugin install wp-content/plugins/hello-world.0.1.0.zip`
1919
Then the wp-content/plugins/hello-world directory should exist
2020
And the wp-content/plugins/hello-world/hello-world.php file should exist
2121
And the wp-content/plugins/hello-world/.travis.yml file should not exist

0 commit comments

Comments
 (0)