From b23650c9d7124470abec7830d0beb51671c7d8f5 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Wed, 19 Sep 2018 19:04:12 -0400 Subject: [PATCH] Automatically move config for upgrade Fixes #635 by detecting if the config directory is in the old location and moving it immediately when running any Valet command. --- cli/includes/helpers.php | 2 ++ cli/valet.php | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/cli/includes/helpers.php b/cli/includes/helpers.php index aeba4711e..8c91b21ad 100644 --- a/cli/includes/helpers.php +++ b/cli/includes/helpers.php @@ -14,6 +14,8 @@ define('VALET_SERVER_PATH', realpath(__DIR__ . '/../../server.php')); define('VALET_STATIC_PREFIX', '41c270e4-5535-4daa-b23e-c269744c2f45'); +define('VALET_LEGACY_HOME_PATH', $_SERVER['HOME'].'/.valet'); + /** * Output the given text to the console. * diff --git a/cli/valet.php b/cli/valet.php index fdb6b0859..3a918690b 100755 --- a/cli/valet.php +++ b/cli/valet.php @@ -17,6 +17,13 @@ use function Valet\table; use function Valet\warning; +/** + * Relocate config dir to ~/.config/valet/ if found in old location. + */ +if (is_dir(VALET_LEGACY_HOME_PATH) && !is_dir(VALET_HOME_PATH)) { + Configuration::createConfigurationDirectory(); +} + /** * Create the application. */