diff --git a/src/Application.php b/src/Application.php index 87ebb5a..ae7de29 100644 --- a/src/Application.php +++ b/src/Application.php @@ -53,6 +53,10 @@ protected function getDefaultInputDefinition() { */ public function doRun(InputInterface $input, OutputInterface $output) { $workingDir = $input->getParameterOption(array('--cwd')); + if (empty($workingDir) && getenv('LOCO_PRJ')) { + $workingDir = getenv('LOCO_PRJ'); + } + if (FALSE !== $workingDir && '' !== $workingDir) { if (!is_dir($workingDir)) { throw new \RuntimeException("Invalid working directory specified, $workingDir does not exist."); diff --git a/src/Command/LocoCommandTrait.php b/src/Command/LocoCommandTrait.php index df9de90..0453b08 100644 --- a/src/Command/LocoCommandTrait.php +++ b/src/Command/LocoCommandTrait.php @@ -4,6 +4,7 @@ use Loco\Loco; use Loco\LocoSystem; use Loco\LocoVolume; +use Loco\Utils\File; use Loco\Utils\Shell; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -47,7 +48,10 @@ public function initSystem(InputInterface $input, OutputInterface $output) { } public function pickConfig() { - $c = Loco::filter('loco.config.find', ['file' => NULL]); + // If you setup an environment with a specific config file (`loco env -c FILE` or `loco shell -c FILE`), then + // the same file should be used in subsequent sub commands (`loco run SVC`). + $envFile = getenv('LOCO_CFG_YML') ? File::toAbsolutePath(getenv('LOCO_CFG_YML')) : NULL; + $c = Loco::filter('loco.config.find', ['file' => $envFile]); if ($c['file']) { return $c['file']; }