From f4281b4eaacc96109ec4801921ec156faf863f24 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Fri, 24 Aug 2018 12:20:13 -0400 Subject: [PATCH] Fix tld php errors from #241 Fixes #618 - PHP errors running TLD command if didn't run `valet install` as part of upgrading from version 2.0.12 --- cli/Valet/Configuration.php | 9 ++++++--- cli/valet.php | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cli/Valet/Configuration.php b/cli/Valet/Configuration.php index c9eee92..2d00627 100644 --- a/cli/Valet/Configuration.php +++ b/cli/Valet/Configuration.php @@ -115,12 +115,15 @@ function writeBaseConfiguration() } /** - * For upgrades, change config key 'domain' to 'tld' + * Migrate old configurations from 'domain' to 'tld' */ $config = $this->read(); - if (isset($config['domain']) && !isset($config['tld'])) { - $this->updateKey('tld', $config['domain']); + + if (isset($config['tld'])) { + return; } + + $this->updateKey('tld', !empty($config['domain']) ? $config['domain'] : 'test'); } /** diff --git a/cli/valet.php b/cli/valet.php index 3dd618f..345bd47 100755 --- a/cli/valet.php +++ b/cli/valet.php @@ -59,6 +59,10 @@ * Get or set the TLD currently being used by Valet. */ $app->command('tld [tld]', function ($tld = null) { + if (empty(Configuration::read()['tld'])) { + Configuration::writeBaseConfiguration(); + } + if ($tld === null) { return info('Valet is configured to serve for TLD: .'.Configuration::read()['tld']); } @@ -74,7 +78,7 @@ Nginx::restart(); info('Your Valet TLD has been updated to ['.$tld.'].'); - }, ['domain'])->descriptions('Get or set the TLD used for Valet sites. (Currently: .'.Configuration::read()['tld'].')'); + }, ['domain'])->descriptions('Get or set the TLD used for Valet sites.'); /** * Add the current working directory to the paths configuration.