Support multiple extra args with spaces

e.g. `versa test --testdox --filter foo`
This commit is contained in:
Oliver Davies 2024-02-22 19:22:42 +00:00
parent 4ebc156137
commit 8c9f36151b
5 changed files with 9 additions and 8 deletions

View file

@ -13,6 +13,7 @@
### Fixed
* Support multiple extra args with spaces, e.g. `versa test --testdox --filter foo`.
* Prevent timeout errors with `versa run`.
## 0.2.0

View file

@ -62,7 +62,7 @@ final class BuildCommand extends AbstractCommand
if ($isDockerCompose) {
$process = Process::create(
command: ['docker', 'compose', 'build'],
extraArgs: $extraArgs,
extraArgs: explode(separator: ' ', string: $extraArgs),
workingDir: $workingDir,
);
@ -77,7 +77,7 @@ final class BuildCommand extends AbstractCommand
case ProjectType::Sculpin->value:
$process = Process::create(
command: ['./vendor/bin/sculpin', 'generate'],
extraArgs: $extraArgs,
extraArgs: explode(separator: ' ', string: $extraArgs),
workingDir: $workingDir,
);
@ -90,7 +90,7 @@ final class BuildCommand extends AbstractCommand
case ProjectType::Fractal->value:
$process = Process::create(
command: ['npx', 'fractal', 'build'],
extraArgs: $extraArgs,
extraArgs: explode(separator: ' ', string: $extraArgs),
workingDir: $workingDir,
);

View file

@ -30,7 +30,7 @@ final class InstallCommand extends AbstractCommand
language: $this->getProjectLanguage($filesystem, $workingDir, $input),
workingDir: $workingDir,
),
extraArgs: $extraArgs,
extraArgs: explode(separator: ' ', string: $extraArgs),
workingDir: $workingDir,
);

View file

@ -32,7 +32,7 @@ final class TestCommand extends AbstractCommand
// TODO: commands in Docker Compose?
$process = Process::create(
command: $command,
extraArgs: $extraArgs,
extraArgs: explode(separator: ' ', string: $extraArgs),
workingDir: $workingDir,
);

View file

@ -14,11 +14,11 @@ final class Process
/**
* @param non-empty-array<int, non-empty-string> $command
* @param string $workingDir
* @param ?string $extraArgs
* @param non-empty-string[] $extraArgs
*/
public static function create(array $command, string $workingDir, ?string $extraArgs = null): SymfonyProcess
public static function create(array $command, string $workingDir, array $extraArgs = []): SymfonyProcess
{
$process = new SymfonyProcess(command: array_filter([...$command, $extraArgs]));
$process = new SymfonyProcess(command: array_filter([...$command, ...$extraArgs]));
$process->setTty(true);
$process->setWorkingDirectory($workingDir);