From f01f7b422db3aad2c715fbcee89be248b43c4e64 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 20 Feb 2024 00:46:48 +0000 Subject: [PATCH] Refactor is Docker Compose check --- versa | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/versa b/versa index 74bc18d..a8851c1 100755 --- a/versa +++ b/versa @@ -41,11 +41,13 @@ $application->addOption( ); $application->setCode(function (InputInterface $input): int { - $filesystem = new Filesystem(); - $extraArgs = $input->getOption('extra-args'); $workingDir = $input->getOption('working-dir'); + $filesystem = new Filesystem(); + + $isDockerCompose = $filesystem->exists($workingDir.'/docker-compose.yaml'); + // TODO: only allow defined commands - build, install, test, run. switch ($input->getArgument('command')) { case 'install': @@ -57,7 +59,7 @@ $application->setCode(function (InputInterface $input): int { break; case 'run': - if ($filesystem->exists($workingDir.'/docker-compose.yaml')) { + if ($isDockerCompose) { $process = new Process(command: array_filter(['docker', 'compose', 'up', $extraArgs])); $process->setTimeout(null); $process->setTty(true);