File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -405,13 +405,13 @@ Feature: Generate a distribution archive of a project with .distignore
405405 When I run `mkdir -p foo/node_modules/package1 foo/node_modules/package2 foo/node_modules/package3`
406406 Then STDERR should be empty
407407
408- When I run `for i in {1..50} ; do touch foo/node_modules/package1/file$i.js; done`
408+ When I run `sh -c 'i=1; while [ $i -le 50 ] ; do touch foo/node_modules/package1/file$i.js; i=$((i+1)); done' `
409409 Then STDERR should be empty
410410
411- When I run `for i in {1..50} ; do touch foo/node_modules/package2/file$i.js; done`
411+ When I run `sh -c 'i=1; while [ $i -le 50 ] ; do touch foo/node_modules/package2/file$i.js; i=$((i+1)); done' `
412412 Then STDERR should be empty
413413
414- When I run `for i in {1..50} ; do touch foo/node_modules/package3/file$i.js; done`
414+ When I run `sh -c 'i=1; while [ $i -le 50 ] ; do touch foo/node_modules/package3/file$i.js; i=$((i+1)); done' `
415415 Then STDERR should be empty
416416
417417 When I run `wp dist-archive foo`
Original file line number Diff line number Diff line change @@ -69,7 +69,16 @@ public function hasChildren() {
6969 }
7070
7171 // For directories, check if they should be ignored.
72- $ relative_filepath = str_replace ( $ this ->source_dir_path , '' , $ item ->getPathname () );
72+ $ pathname = $ item ->getPathname ();
73+ $ source_path_length = strlen ( $ this ->source_dir_path );
74+
75+ // Extract relative path by removing the source directory prefix.
76+ if ( 0 === strpos ( $ pathname , $ this ->source_dir_path ) ) {
77+ $ relative_filepath = substr ( $ pathname , $ source_path_length );
78+ } else {
79+ // Fallback if path doesn't start with source path (shouldn't happen).
80+ $ relative_filepath = $ pathname ;
81+ }
7382
7483 try {
7584 $ is_ignored = $ this ->checker ->isPathIgnored ( $ relative_filepath );
@@ -87,6 +96,8 @@ public function hasChildren() {
8796 // This is a top-level ignored directory like "/node_modules" or "/.git".
8897 // It's likely safe to skip descent as these are typically simple patterns.
8998 // However, we still need to be conservative. Let's check if a child would be ignored.
99+ // We use 'test' as a probe filename to check if children would be ignored.
100+ // The actual name doesn't matter; we just need to verify the pattern applies to children.
90101 $ test_child = $ relative_filepath . '/test ' ;
91102 try {
92103 $ child_ignored = $ this ->checker ->isPathIgnored ( $ test_child );
You can’t perform that action at this time.
0 commit comments