Skip to content

Commit

Permalink
Merge pull request #10 from totten/master-inherit
Browse files Browse the repository at this point in the history
Re-use config file in subshells
  • Loading branch information
totten authored Jan 30, 2023
2 parents b5b5706 + 002168e commit f6553bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
6 changes: 5 additions & 1 deletion src/Command/LocoCommandTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'];
}
Expand Down

0 comments on commit f6553bb

Please sign in to comment.