Skip to content

Commit b076474

Browse files
committed
Delete only phar's which are managed by tooly, fixes #12
1 parent d75cf73 commit b076474

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Script/Processor.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,24 @@ private function getDecisions()
128128
*/
129129
private function removeFromDir($dir, array $excludeToolNames = [])
130130
{
131+
// Get the tools managed by tooly
132+
$tools = $this->configuration->getTools();
133+
131134
foreach (scandir($dir) as $entry) {
132135
$path = $dir . DIRECTORY_SEPARATOR . $entry;
133136

134137
if (false === strpos($path, '.phar')) {
135138
continue;
136139
}
137140

141+
/* @var $tool Tool */
142+
foreach ($tools as $tool) {
143+
// Check if the binary is a managed one by tooly, if not - don't remove it
144+
if (basename($tool->getFilename()) !== basename($path)) {
145+
continue 2;
146+
}
147+
}
148+
138149
if (true === in_array(basename($entry, '.phar'), $excludeToolNames)) {
139150
continue;
140151
}

0 commit comments

Comments
 (0)