Skip to content

Commit 29cb9ca

Browse files
Properly ignore .DS_Store in the top-level directory and subdirs
1 parent 307431c commit 29cb9ca

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

features/dist-archive.feature

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,45 @@ Feature: Generate a distribution archive of a project
106106
And the foo/composer.json file should exist
107107
And the foo/.distignore file should not exist
108108
And the foo/features/sample.feature file should not exist
109+
110+
Scenario Outline: Ignores hidden files in subdirectories
111+
Given an empty directory
112+
And a foo/.distignore file:
113+
"""
114+
.DS_Store
115+
"""
116+
And a foo/test.php file:
117+
"""
118+
<?php
119+
echo 'Hello world;';
120+
"""
121+
And a foo/test-dir/test.php file:
122+
"""
123+
<?php
124+
echo 'Hello world;';
125+
"""
126+
And a foo/test-dir/.DS_Store file:
127+
"""
128+
Bad!
129+
"""
130+
131+
When I run `wp dist-archive foo --format=<format>`
132+
Then STDOUT should be:
133+
"""
134+
Success: Created foo.<extension>
135+
"""
136+
And the foo.<extension> file should exist
137+
138+
When I run `rm -rf foo`
139+
Then the foo directory should not exist
140+
141+
When I run `<extract> foo.<extension>`
142+
Then the foo directory should exist
143+
And the foo/test.php file should exist
144+
And the foo/test-dir/test.php file should exist
145+
And the foo/test-dir/.DS_Store file should not exist
146+
147+
Examples:
148+
| format | extension | extract |
149+
| zip | zip | unzip |
150+
| targz | tar.gz | tar -zxvf |

src/Dist_Archive_Command.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ public function __invoke( $args, $assoc_args ) {
7777
if ( is_dir( $path . '/' . $file ) ) {
7878
$file = rtrim( $file, '/' ) . '/*';
7979
}
80-
$ignored_files[] = $archive_base . '/' . $file;
80+
if ( 'zip' === $assoc_args['format'] ) {
81+
$ignored_files[] = '*/' . $file;
82+
} elseif ( 'targz' === $assoc_args['format'] ) {
83+
$ignored_files[] = $file;
84+
}
8185
}
8286

8387
$version = '';

0 commit comments

Comments
 (0)