Skip to content

Commit 3ea2a17

Browse files
authored
Create ComposerScripts.php
1 parent a7637b9 commit 3ea2a17

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/ComposerScripts.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
}

0 commit comments

Comments
 (0)