function TemplateProjectTestBase::runComposer
Runs a Composer command and returns its output.
Always asserts that the command was executed successfully.
Parameters
string $command: The command to execute, including the `composer` invocation.
string|null $working_dir: (optional) A working directory relative to the workspace, within which to execute the command. Defaults to the workspace directory.
bool $json: (optional) Whether to parse the command's output as JSON before returning it. Defaults to FALSE.
Return value
mixed|string|null The command's output, optionally parsed as JSON.
File
-
core/
modules/ package_manager/ tests/ src/ Build/ TemplateProjectTestBase.php, line 512
Class
- TemplateProjectTestBase
- Base class for tests which create a test site from a core project template.
Namespace
Drupal\Tests\package_manager\BuildCode
protected function runComposer(string $command, ?string $working_dir = NULL, bool $json = FALSE) {
$process = $this->executeCommand($command, $working_dir);
$this->assertCommandSuccessful();
$output = trim($process->getOutput());
if ($json) {
$output = json_decode($output, TRUE, flags: JSON_THROW_ON_ERROR);
}
return $output;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.