Skip to content

Commit

Permalink
Pass default domain to remote drush command (#1694)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmott-littler authored Mar 4, 2024
1 parent 2be1509 commit d7af9cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Command/Remote/DrushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
$environment = $this->determineEnvironment($input, $output);
$alias = self::getEnvironmentAlias($environment);
$acliArguments = $input->getArguments();
$drushArguments = (array) $acliArguments['drush_command'];
// When available, provide the default domain to drush
if (!empty($environment->default_domain)) {
// Insert at the beginning so a user-supplied --uri arg will override
array_unshift($drushArguments, "--uri=http://{$environment->default_domain}");
}
$drushCommandArguments = [
"cd /var/www/html/$alias/docroot; ",
'drush',
implode(' ', (array) $acliArguments['drush_command']),
implode(' ', $drushArguments),
];

return $this->sshHelper->executeCommand($environment, $drushCommandArguments)->getExitCode();
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/src/Commands/Remote/DrushCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testRemoteDrushCommand(array $args): void {
'-o LogLevel=ERROR',
'cd /var/www/html/site.dev/docroot; ',
'drush',
'status --fields=db-status',
'--uri=http://sitedev.hosted.acquia-sites.com status --fields=db-status',
];
$localMachineHelper
->execute($sshCommand, Argument::type('callable'), NULL, TRUE, NULL)
Expand Down

0 comments on commit d7af9cf

Please sign in to comment.