composer/composer#7159: make the remove command to a regex lookup on package name

- if you have multiple vendor modules installed you should be able to do composer remove vendor/* to remove all
 - update remove and also remove from alternative type to also do a preg_grep for what the user has inputed
main
David Manners 6 years ago
parent 041028920f
commit a1ab75a703

@ -100,6 +100,19 @@ EOT
$json->removeLink($altType, $composer[$altType][$package]); $json->removeLink($altType, $composer[$altType][$package]);
} }
} }
} elseif (isset($composer[$type]) && $matches = preg_grep('#^'.$package.'#', array_keys($composer[$type]))) {
foreach ($matches as $matchedPackage) {
$json->removeLink($type, $matchedPackage);
}
} elseif (isset($composer[$altType]) && $matches = preg_grep('#^'.$package.'#', array_keys($composer[$altType]))) {
foreach ($matches as $matchedPackage) {
$io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
if ($io->isInteractive()) {
if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ', true)) {
$json->removeLink($altType, $matchedPackage);
}
}
}
} else { } else {
$io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>'); $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
} }

Loading…
Cancel
Save