Skip to content

Instantly share code, notes, and snippets.

@ivuorinen
Created September 18, 2022 08:33
Show Gist options
  • Save ivuorinen/d7ddf52308b727c5e8ad862f5fec403b to your computer and use it in GitHub Desktop.
Save ivuorinen/d7ddf52308b727c5e8ad862f5fec403b to your computer and use it in GitHub Desktop.
Remove all vendor and node_modules folders from cli
<?php
system("df -H");
echo "\n\n";
$d = glob(__DIR__ . '/*');
sort($d);
$removable = [
'vendor',
'node_modules'
];
foreach ($d as $folder) {
if (!is_dir($folder)) {
continue;
}
echo print_r($folder, true) . "\n";
foreach ($removable as $item) {
$f = $folder . DIRECTORY_SEPARATOR . $item;
if (!file_exists($f)) {
continue;
}
echo " -> (!) Removing: " . $f . "\n";
system("rm -rf $f");
echo "\n";
}
}
echo "\n\n";
system("df -H");
echo "\n\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment