|
30 | 30 | * <path> |
31 | 31 | * : Path to the project that includes a .distignore file. |
32 | 32 | * |
| 33 | + * [<target>] |
| 34 | + * : Path and file name for the distribution archive. Defaults to project directory name plus version, if discoverable. |
| 35 | + * |
33 | 36 | * [--format=<format>] |
34 | 37 | * : Choose the format for the archive. |
35 | 38 | * --- |
|
44 | 47 | $dist_archive_command = function( $args, $assoc_args ) { |
45 | 48 |
|
46 | 49 | list( $path ) = $args; |
| 50 | + if ( isset( $args[1] ) ) { |
| 51 | + $archive_file = $args[1]; |
| 52 | + $info = pathinfo( $archive_file ); |
| 53 | + if ( '.' === $info['dirname'] ) { |
| 54 | + $archive_file = getcwd() . '/' . $info['basename']; |
| 55 | + } |
| 56 | + } else { |
| 57 | + $archive_file = null; |
| 58 | + } |
47 | 59 | $path = rtrim( realpath( $path ), '/' ); |
48 | 60 | if ( ! is_dir( $path ) ) { |
49 | 61 | WP_CLI::error( 'Provided path is not a directory.' ); |
|
78 | 90 | } |
79 | 91 |
|
80 | 92 | if ( 'zip' === $assoc_args['format'] ) { |
81 | | - $archive_file = $archive_base . $version . '.zip'; |
| 93 | + if ( is_null( $archive_file ) ) { |
| 94 | + $archive_file = dirname( $path ) . '/' . $archive_base . $version . '.zip'; |
| 95 | + } |
82 | 96 | $excludes = implode( ' --exclude ', $ignored_files ); |
83 | 97 | if ( ! empty( $excludes ) ) { |
84 | 98 | $excludes = ' --exclude ' . $excludes; |
|
88 | 102 | WP_CLI::debug( "Running: {$cmd}", 'dist-archive' ); |
89 | 103 | $ret = WP_CLI::launch( escapeshellcmd( $cmd ), false, true ); |
90 | 104 | if ( 0 === $ret->return_code ) { |
91 | | - WP_CLI::success( "Created {$archive_file}" ); |
| 105 | + $filename = pathinfo( $archive_file, PATHINFO_BASENAME ); |
| 106 | + WP_CLI::success( "Created {$filename}" ); |
92 | 107 | } else { |
93 | 108 | $error = $ret->stderr ? $ret->stderr : $ret->stdout; |
94 | 109 | WP_CLI::error( $error ); |
|
0 commit comments