Skip to content

Commit 266bd64

Browse files
Merge pull request #33 from wp-cli/hidden-directories
Ensure hidden subdirectories of directories are ignored too
2 parents da45ef5 + fdebe85 commit 266bd64

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

features/find.feature

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ Feature: Find WordPress installs on the filesystem
181181
Scenario: Ignore hidden directories by default
182182
Given a WP install in 'subdir1'
183183
And a WP install in '.svn'
184+
And I run `mkdir -p subdir2/.svn`
185+
And a WP install in 'subdir2/.svn/wp-install'
184186

185187
When I run `wp eval --skip-wordpress 'echo realpath( getenv( "RUN_DIR" ) );'`
186188
Then save STDOUT as {TEST_DIR}
@@ -194,5 +196,5 @@ Feature: Find WordPress installs on the filesystem
194196
When I run `wp find {TEST_DIR} --skip-ignored-paths --format=count`
195197
Then STDOUT should be:
196198
"""
197-
2
199+
3
198200
"""

src/Find_Command.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ private function recurse_directory( $path ) {
200200
// Assume base path doesn't need comparison
201201
$compared_path = preg_replace( '#^' . preg_quote( $this->base_path ) . '#', '', $path );
202202
// Ignore all hidden system directories
203-
if ( '/.' === substr( $compared_path, 0, 2 ) ) {
203+
$bits = explode( '/', trim( $compared_path, '/' ) );
204+
$current_dir = array_pop( $bits );
205+
if ( $current_dir && '.' === $current_dir[0] ) {
204206
$this->log( "Matched ignored path. Skipping recursion into '{$path}'" );
205207
return;
206208
}

0 commit comments

Comments
 (0)