From 6f8c14271a38b0bdd0dd2b5c08b534b82a3b6ea7 Mon Sep 17 00:00:00 2001 From: Antonio Carlos Ribeiro Date: Tue, 21 Feb 2017 12:04:45 -0300 Subject: [PATCH] Show install, start, stop and restart log info --- cli/Valet/Brew.php | 16 +++++++++++++--- cli/Valet/Nginx.php | 6 ++++++ cli/Valet/PhpFpm.php | 2 ++ tests/BrewTest.php | 2 ++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cli/Valet/Brew.php b/cli/Valet/Brew.php index 6f220ad..cf2e42a 100644 --- a/cli/Valet/Brew.php +++ b/cli/Valet/Brew.php @@ -91,6 +91,8 @@ function ensureInstalled($formula, $options = [], $taps = []) */ function installOrFail($formula, $options = [], $taps = []) { + info("Installing $formula..."); + if (count($taps) > 0) { $this->tap($taps); } @@ -129,8 +131,12 @@ function restartService($services) $services = is_array($services) ? $services : func_get_args(); foreach ($services as $service) { - $this->cli->quietly('sudo brew services stop '.$service); - $this->cli->quietly('sudo brew services start '.$service); + if ($this->installed($service)) { + info("Restarting $service..."); + + $this->cli->quietly('sudo brew services stop '.$service); + $this->cli->quietly('sudo brew services start '.$service); + } } } @@ -144,7 +150,11 @@ function stopService($services) $services = is_array($services) ? $services : func_get_args(); foreach ($services as $service) { - $this->cli->quietly('sudo brew services stop '.$service); + if ($this->installed($service)) { + info("Stopping $service..."); + + $this->cli->quietly('sudo brew services stop '.$service); + } } } diff --git a/cli/Valet/Nginx.php b/cli/Valet/Nginx.php index a6ca027..3810b1e 100644 --- a/cli/Valet/Nginx.php +++ b/cli/Valet/Nginx.php @@ -53,6 +53,8 @@ function install() */ function installConfiguration() { + info('Installing nginx configuration...'); + $contents = $this->files->get(__DIR__.'/../stubs/nginx.conf'); $this->files->putAsUser( @@ -94,6 +96,8 @@ function installServer() */ function installNginxDirectory() { + info('Installing nginx directory...'); + if (! $this->files->isDir($nginxDirectory = VALET_HOME_PATH.'/Nginx')) { $this->files->mkdirAsUser($nginxDirectory); } @@ -132,6 +136,8 @@ function restart() */ function stop() { + info('Stopping nginx....'); + $this->cli->quietly('sudo brew services stop '. $this->brew->nginxServiceName()); } diff --git a/cli/Valet/PhpFpm.php b/cli/Valet/PhpFpm.php index 3c7f847..83f4783 100644 --- a/cli/Valet/PhpFpm.php +++ b/cli/Valet/PhpFpm.php @@ -54,6 +54,8 @@ function install() */ function updateConfiguration() { + info('Updating php configuration...'); + $contents = $this->files->get($this->fpmConfigPath()); $contents = preg_replace('/^user = .+$/m', 'user = '.user(), $contents); diff --git a/tests/BrewTest.php b/tests/BrewTest.php index 79d977b..aac2a32 100644 --- a/tests/BrewTest.php +++ b/tests/BrewTest.php @@ -99,6 +99,7 @@ public function test_tap_taps_the_given_homebrew_repository() public function test_restart_restarts_the_service_using_homebrew_services() { $cli = Mockery::mock(CommandLine::class); + $cli->shouldReceive('runAsUser')->once()->with('brew list | grep dnsmasq')->andReturn('dnsmasq'); $cli->shouldReceive('quietly')->once()->with('sudo brew services stop dnsmasq'); $cli->shouldReceive('quietly')->once()->with('sudo brew services start dnsmasq'); swap(CommandLine::class, $cli); @@ -109,6 +110,7 @@ public function test_restart_restarts_the_service_using_homebrew_services() public function test_stop_stops_the_service_using_homebrew_services() { $cli = Mockery::mock(CommandLine::class); + $cli->shouldReceive('runAsUser')->once()->with('brew list | grep dnsmasq')->andReturn('dnsmasq'); $cli->shouldReceive('quietly')->once()->with('sudo brew services stop dnsmasq'); swap(CommandLine::class, $cli); resolve(Brew::class)->stopService('dnsmasq');