function Fixtures::runComposer

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Fixtures.php \Drupal\Tests\Composer\Plugin\Scaffold\Fixtures::runComposer()
  2. 8.9.x core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Fixtures.php \Drupal\Tests\Composer\Plugin\Scaffold\Fixtures::runComposer()

Runs a `composer` command.

Parameters

string $cmd: The Composer command to execute (escaped as required)

string $cwd: The current working directory to run the command from.

Return value

string Standard output and standard error from the command.

File

core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Fixtures.php, line 386

Class

Fixtures
Convenience class for creating fixtures.

Namespace

Drupal\Tests\Composer\Plugin\Scaffold

Code

public function runComposer($cmd, $cwd) {
  chdir($cwd);
  $input = new StringInput($cmd);
  $output = new BufferedOutput();
  $application = new Application();
  $application->setAutoExit(FALSE);
  $exitCode = $application->run($input, $output);
  $output = $output->fetch();
  if ($exitCode != 0) {
    throw new \Exception("Fixtures::runComposer failed to set up fixtures.\n\nCommand: '{$cmd}'\nExit code: {$exitCode}\nOutput: \n\n{$output}");
  }
  return $output;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.