1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-06 08:40:09 +01:00

Show install, start, stop and restart log info

This commit is contained in:
Antonio Carlos Ribeiro
2017-02-21 12:04:45 -03:00
parent 2e0e2c1fa4
commit 6f8c14271a
4 changed files with 23 additions and 3 deletions

View File

@@ -91,6 +91,8 @@ function ensureInstalled($formula, $options = [], $taps = [])
*/ */
function installOrFail($formula, $options = [], $taps = []) function installOrFail($formula, $options = [], $taps = [])
{ {
info("Installing $formula...");
if (count($taps) > 0) { if (count($taps) > 0) {
$this->tap($taps); $this->tap($taps);
} }
@@ -129,8 +131,12 @@ function restartService($services)
$services = is_array($services) ? $services : func_get_args(); $services = is_array($services) ? $services : func_get_args();
foreach ($services as $service) { foreach ($services as $service) {
$this->cli->quietly('sudo brew services stop '.$service); if ($this->installed($service)) {
$this->cli->quietly('sudo brew services start '.$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(); $services = is_array($services) ? $services : func_get_args();
foreach ($services as $service) { 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);
}
} }
} }

View File

@@ -53,6 +53,8 @@ function install()
*/ */
function installConfiguration() function installConfiguration()
{ {
info('Installing nginx configuration...');
$contents = $this->files->get(__DIR__.'/../stubs/nginx.conf'); $contents = $this->files->get(__DIR__.'/../stubs/nginx.conf');
$this->files->putAsUser( $this->files->putAsUser(
@@ -94,6 +96,8 @@ function installServer()
*/ */
function installNginxDirectory() function installNginxDirectory()
{ {
info('Installing nginx directory...');
if (! $this->files->isDir($nginxDirectory = VALET_HOME_PATH.'/Nginx')) { if (! $this->files->isDir($nginxDirectory = VALET_HOME_PATH.'/Nginx')) {
$this->files->mkdirAsUser($nginxDirectory); $this->files->mkdirAsUser($nginxDirectory);
} }
@@ -132,6 +136,8 @@ function restart()
*/ */
function stop() function stop()
{ {
info('Stopping nginx....');
$this->cli->quietly('sudo brew services stop '. $this->brew->nginxServiceName()); $this->cli->quietly('sudo brew services stop '. $this->brew->nginxServiceName());
} }

View File

@@ -54,6 +54,8 @@ function install()
*/ */
function updateConfiguration() function updateConfiguration()
{ {
info('Updating php configuration...');
$contents = $this->files->get($this->fpmConfigPath()); $contents = $this->files->get($this->fpmConfigPath());
$contents = preg_replace('/^user = .+$/m', 'user = '.user(), $contents); $contents = preg_replace('/^user = .+$/m', 'user = '.user(), $contents);

View File

@@ -99,6 +99,7 @@ public function test_tap_taps_the_given_homebrew_repository()
public function test_restart_restarts_the_service_using_homebrew_services() public function test_restart_restarts_the_service_using_homebrew_services()
{ {
$cli = Mockery::mock(CommandLine::class); $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 stop dnsmasq');
$cli->shouldReceive('quietly')->once()->with('sudo brew services start dnsmasq'); $cli->shouldReceive('quietly')->once()->with('sudo brew services start dnsmasq');
swap(CommandLine::class, $cli); 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() public function test_stop_stops_the_service_using_homebrew_services()
{ {
$cli = Mockery::mock(CommandLine::class); $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 stop dnsmasq');
swap(CommandLine::class, $cli); swap(CommandLine::class, $cli);
resolve(Brew::class)->stopService('dnsmasq'); resolve(Brew::class)->stopService('dnsmasq');