Skip to content

Commit 345c9e0

Browse files
committed
fixes
1 parent 8a93694 commit 345c9e0

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/Dist_Archive_Command.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public function __invoke( $args, $assoc_args ) {
4949
list( $path ) = $args;
5050
if ( isset( $args[1] ) ) {
5151
$archive_file = $args[1];
52-
$info = pathinfo( $archive_file );
52+
$info = pathinfo( $archive_file );
5353
if ( '.' === $info['dirname'] ) {
54-
$archive_file = getcwd() . '/' . $info['basename'];
54+
$archive_file = getcwd() . '/' . $info['basename'];
5555
}
5656
} else {
5757
$archive_file = null;
@@ -67,9 +67,9 @@ public function __invoke( $args, $assoc_args ) {
6767
}
6868

6969
$maybe_ignored_files = explode( PHP_EOL, file_get_contents( $dist_ignore_path ) );
70-
$ignored_files = array();
71-
$archive_base = basename( $path );
72-
foreach( $maybe_ignored_files as $file ) {
70+
$ignored_files = array();
71+
$archive_base = basename( $path );
72+
foreach ( $maybe_ignored_files as $file ) {
7373
$file = trim( $file );
7474
if ( 0 === strpos( $file, '#' ) || empty( $file ) ) {
7575
continue;
@@ -85,7 +85,7 @@ public function __invoke( $args, $assoc_args ) {
8585
}
8686

8787
$version = '';
88-
foreach( glob( $path . '/*.php' ) as $php_file ) {
88+
foreach ( glob( $path . '/*.php' ) as $php_file ) {
8989
$contents = file_get_contents( $php_file, false, null, 0, 5000 );
9090
if ( preg_match( '#\* Version:(.+)#', $contents, $matches ) ) {
9191
$version = '.' . trim( $matches[1] );
@@ -101,7 +101,7 @@ public function __invoke( $args, $assoc_args ) {
101101
}
102102

103103
if ( false !== stripos( $version, '-alpha' ) && is_dir( $path . '/.git' ) ) {
104-
$response = WP_CLI::launch( "cd {$path}; git log --pretty=format:'%h' -n 1", false, true );
104+
$response = WP_CLI::launch( "cd {$path}; git log --pretty=format:'%h' -n 1", false, true );
105105
$maybe_hash = trim( $response->stdout );
106106
if ( $maybe_hash && 7 === strlen( $maybe_hash ) ) {
107107
$version .= '-' . $maybe_hash;
@@ -112,7 +112,7 @@ public function __invoke( $args, $assoc_args ) {
112112
$archive_file = dirname( $path ) . '/' . $archive_base . $version;
113113
if ( 'zip' === $assoc_args['format'] ) {
114114
$archive_file .= '.zip';
115-
} else if ( 'targz' === $assoc_args['format'] ) {
115+
} elseif ( 'targz' === $assoc_args['format'] ) {
116116
$archive_file .= '.tar.gz';
117117
}
118118
}
@@ -125,15 +125,17 @@ public function __invoke( $args, $assoc_args ) {
125125
$excludes = ' --exclude ' . $excludes;
126126
}
127127
$cmd = "zip -r {$archive_file} {$archive_base} {$excludes}";
128-
} else if ( 'targz' === $assoc_args['format'] ) {
129-
$excludes = array_map( function( $ignored_file ){
130-
if ( '/*' === substr( $ignored_file, -2 ) ) {
131-
$ignored_file = substr( $ignored_file, 0, ( strlen( $ignored_file ) - 2 ) );
132-
}
133-
return "--exclude='{$ignored_file}'";
134-
}, $ignored_files );
128+
} elseif ( 'targz' === $assoc_args['format'] ) {
129+
$excludes = array_map(
130+
function( $ignored_file ) {
131+
if ( '/*' === substr( $ignored_file, -2 ) ) {
132+
$ignored_file = substr( $ignored_file, 0, ( strlen( $ignored_file ) - 2 ) );
133+
}
134+
return "--exclude='{$ignored_file}'";
135+
}, $ignored_files
136+
);
135137
$excludes = implode( ' ', $excludes );
136-
$cmd = "tar {$excludes} -zcvf {$archive_file} {$archive_base}";
138+
$cmd = "tar {$excludes} -zcvf {$archive_file} {$archive_base}";
137139
}
138140

139141
WP_CLI::debug( "Running: {$cmd}", 'dist-archive' );

0 commit comments

Comments
 (0)