Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pm:install and pm:uninstall respect --simulate option #5152

Merged
merged 3 commits into from Jun 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Drupal/Commands/pm/PmCommands.php
Expand Up @@ -69,6 +69,9 @@ public function getExtensionListModule(): ModuleExtensionList
* @param $modules A comma delimited list of modules.
* @aliases in, install, pm-install, en, pm-enable, pm:enable
* @bootstrap root
*
* @usage drush pm:install --simulate content_moderation
* Display what modules would be installed but don't install them.
*/
public function install(array $modules): void
{
Expand All @@ -78,6 +81,9 @@ public function install(array $modules): void
if (empty($todo)) {
$this->logger()->notice(dt('Already enabled: !list', ['!list' => implode(', ', $modules)]));
return;
} elseif (Drush::simulate()) {
$this->output()->writeln(dt('The following module(s) will be enabled: !list', $todo_str));
return;
} elseif (array_values($todo) !== $modules) {
$this->output()->writeln(dt('The following module(s) will be enabled: !list', $todo_str));
if (!$this->io()->confirm(dt('Do you want to continue?'))) {
Expand Down Expand Up @@ -156,11 +162,19 @@ public function validateEnableModules(CommandData $commandData): void
* @command pm:uninstall
* @param $modules A comma delimited list of modules.
* @aliases un,pmu,pm-uninstall
*
* @usage drush pm:uninstall --simulate field_ui
* Display what modules would be uninstalled but don't uninstall them.
*/
public function uninstall(array $modules): void
{
$modules = StringUtils::csvToArray($modules);
$list = $this->addUninstallDependencies($modules);
if (Drush::simulate()) {
$this->output()->writeln(dt('The following extensions will be uninstalled: !list', ['!list' => implode(', ', $list)]));
return;
}

if (array_values($list) !== $modules) {
$this->output()->writeln(dt('The following extensions will be uninstalled: !list', ['!list' => implode(', ', $list)]));
if (!$this->io()->confirm(dt('Do you want to continue?'))) {
Expand Down