File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace GrimPirate \Halberd ;
4+
5+ class ComposerScripts
6+ {
7+ public function postUpdate (array $ params )
8+ {
9+ echo __DIR__ ;
10+ }
11+
12+ private function removeDir (string $ dir ): void
13+ {
14+ // Create RecursiveDirectoryIterator with SKIP_DOTS flag to ignore '.' and '..'
15+ $ it = new \RecursiveDirectoryIterator ($ dir , \RecursiveDirectoryIterator::SKIP_DOTS );
16+ // Create RecursiveIteratorIterator with CHILD_FIRST flag to ensure child items are processed first
17+ $ files = new \RecursiveIteratorIterator ($ it , \RecursiveIteratorIterator::CHILD_FIRST );
18+
19+ foreach ($ files as $ file )
20+ {
21+ if ($ file ->isDir ())
22+ {
23+ // Remove directory
24+ rmdir ($ file ->getPathname ());
25+ }
26+ else
27+ {
28+ // Delete file
29+ unlink ($ file ->getPathname ());
30+ }
31+ }
32+ // Remove the main directory after its contents are empty
33+ rmdir ($ dir );
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments