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 ### Fixed
* Support multiple extra args with spaces, e.g. `versa test --testdox --filter foo`.
* Prevent timeout errors with `versa run`. * Prevent timeout errors with `versa run`.
## 0.2.0 ## 0.2.0

View file

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

View file

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

View file

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

View file

@ -14,11 +14,11 @@ final class Process
/** /**
* @param non-empty-array<int, non-empty-string> $command * @param non-empty-array<int, non-empty-string> $command
* @param string $workingDir * @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->setTty(true);
$process->setWorkingDirectory($workingDir); $process->setWorkingDirectory($workingDir);