From 39ef0d60eefdc60fe60358d3aa5b64ad28884159 Mon Sep 17 00:00:00 2001 From: Georg Grossberger Date: Tue, 22 Sep 2015 13:10:39 +0200 Subject: [PATCH] Allow custom sync config locations Add a check for the environment variable "SYNC_CONFIG" which is used to find a configuration file. This allows to place the files at a different location than the acutal project, making re-use of configurations easier. Example SYNC_CONFIG="$HOME/sync-projecta.yml" ct sync:server staging The default behaviour is not altered by this change. --- .../CliTools/Console/Command/Sync/AbstractCommand.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/CliTools/Console/Command/Sync/AbstractCommand.php b/src/app/CliTools/Console/Command/Sync/AbstractCommand.php index 979707b..7b0365d 100644 --- a/src/app/CliTools/Console/Command/Sync/AbstractCommand.php +++ b/src/app/CliTools/Console/Command/Sync/AbstractCommand.php @@ -42,8 +42,9 @@ abstract class AbstractCommand extends \CliTools\Console\Command\AbstractCommand { - const CONFIG_FILE = 'clisync.yml'; - const GLOBAL_KEY = 'GLOBAL'; + const CONFIG_FILE = 'clisync.yml'; + const GLOBAL_KEY = 'GLOBAL'; + const CONFIG_ENVKEY = 'SYNC_CONFIG'; /** * Config area @@ -187,6 +188,12 @@ protected function findConfigurationInPath() '.' . self::CONFIG_FILE, ); + if (getenv(self::CONFIG_ENVKEY) !== FALSE) { + array_unshift($confFileList, getenv(self::CONFIG_ENVKEY)); + array_unshift($confFileList, getenv(self::CONFIG_ENVKEY) . DIRECTORY_SEPARATOR . self::CONFIG_FILE); + array_unshift($confFileList, getenv(self::CONFIG_ENVKEY) . DIRECTORY_SEPARATOR . '.' . self::CONFIG_FILE); + } + // Find configuration file $this->confFilePath = UnixUtility::findFileInDirectortyTree($confFileList); if (empty($this->confFilePath)) {