Skip to content

Commit

Permalink
Merge pull request #1003 from soilSpoon/feature/brew
Browse files Browse the repository at this point in the history
Update brew list command to remove deprecation warning
  • Loading branch information
mattstauffer authored Nov 27, 2020
2 parents 21f0549 + cbb59c2 commit 3f0f157
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions cli/Valet/Brew.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function __construct(CommandLine $cli, Filesystem $files)
*/
function installed($formula)
{
return in_array($formula, explode(PHP_EOL, $this->cli->runAsUser('brew list | grep '.$formula)));
return in_array($formula, explode(PHP_EOL, $this->cli->runAsUser('brew list --formula | grep '.$formula)));
}

/**
Expand Down Expand Up @@ -354,7 +354,7 @@ function ($exitCode, $errorOutput) {

/**
* Tell Homebrew to forcefully remove all PHP versions that Valet supports.
*
*
* @return string
*/
function uninstallAllPhpVersions()
Expand All @@ -369,7 +369,7 @@ function uninstallAllPhpVersions()
/**
* Uninstall a Homebrew app by formula name.
* @param string $formula
*
*
* @return void
*/
function uninstallFormula($formula)
Expand All @@ -380,7 +380,7 @@ function uninstallFormula($formula)

/**
* Run Homebrew's cleanup commands.
*
*
* @return string
*/
function cleanupBrew()
Expand Down
2 changes: 1 addition & 1 deletion cli/Valet/Diagnose.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Diagnose
'brew update > /dev/null 2>&1',
'brew config',
'brew services list',
'brew list --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"',
'brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"',
'brew outdated',
'php -v',
'which -a php',
Expand Down
6 changes: 3 additions & 3 deletions cli/valet.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
Run <info>composer global remove laravel/valet</info>
and then <info>rm /usr/local/bin/valet</info> to remove the Valet bin link if it still exists.
Optional:
- <info>brew list</info> will show any other Homebrew services installed, in case you want to make changes to those as well.
- <info>brew list --formula</info> will show any other Homebrew services installed, in case you want to make changes to those as well.
- <info>brew doctor</info> can indicate if there might be any broken things left behind.
- <info>brew cleanup</info> can purge old cached Homebrew downloads.
<fg=red>If you had customized your Mac DNS settings in System Preferences->Network, you will need to remove 127.0.0.1 from that list.</>
Expand Down Expand Up @@ -402,14 +402,14 @@
<info>4. Homebrew Services</info>
<fg=red>You may remove the core services (php, nginx, dnsmasq) by running:</> <comment>brew uninstall --force php nginx dnsmasq</comment>
<fg=red>You can then remove selected leftover configurations for these services manually</> in both <comment>".BREW_PREFIX."/etc/</comment> and <comment>".BREW_PREFIX."/logs/</comment>.
(If you have other PHP versions installed, run <info>brew list | grep php</info> to see which versions you should also uninstall manually.)
(If you have other PHP versions installed, run <info>brew list --formula | grep php</info> to see which versions you should also uninstall manually.)
<error>BEWARE:</error> Uninstalling PHP via Homebrew will leave your Mac with its original PHP version, which may not be compatible with other Composer dependencies you have installed. Thus you may get unexpected errors.
Some additional services which you may have installed (but which Valet does not directly configure or manage) include: <comment>mariadb mysql mailhog</comment>.
If you wish to also remove them, you may manually run <comment>brew uninstall SERVICENAME</comment> and clean up their configurations in ".BREW_PREFIX."/etc if necessary.
You can discover more Homebrew services by running: <comment>brew services list</comment> and <comment>brew list</comment>
You can discover more Homebrew services by running: <comment>brew services list</comment> and <comment>brew list --formula</comment>
<fg=red>If you have customized your Mac DNS settings in System Preferences->Network, you may need to add or remove 127.0.0.1 from the top of that list.</>
Expand Down
14 changes: 7 additions & 7 deletions tests/BrewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public function test_brew_can_be_resolved_from_container()
public function test_installed_returns_true_when_given_formula_is_installed()
{
$cli = Mockery::mock(CommandLine::class);
$cli->shouldReceive('runAsUser')->once()->with('brew list | grep [email protected]')->andReturn('[email protected]');
$cli->shouldReceive('runAsUser')->once()->with('brew list --formula | grep [email protected]')->andReturn('[email protected]');
swap(CommandLine::class, $cli);
$this->assertTrue(resolve(Brew::class)->installed('[email protected]'));

$cli = Mockery::mock(CommandLine::class);
$cli->shouldReceive('runAsUser')->once()->with('brew list | grep php')->andReturn('php
$cli->shouldReceive('runAsUser')->once()->with('brew list --formula | grep php')->andReturn('php
[email protected]');
swap(CommandLine::class, $cli);
$this->assertTrue(resolve(Brew::class)->installed('php'));
Expand All @@ -49,17 +49,17 @@ public function test_installed_returns_true_when_given_formula_is_installed()
public function test_installed_returns_false_when_given_formula_is_not_installed()
{
$cli = Mockery::mock(CommandLine::class);
$cli->shouldReceive('runAsUser')->once()->with('brew list | grep [email protected]')->andReturn('');
$cli->shouldReceive('runAsUser')->once()->with('brew list --formula | grep [email protected]')->andReturn('');
swap(CommandLine::class, $cli);
$this->assertFalse(resolve(Brew::class)->installed('[email protected]'));

$cli = Mockery::mock(CommandLine::class);
$cli->shouldReceive('runAsUser')->once()->with('brew list | grep [email protected]')->andReturn('php');
$cli->shouldReceive('runAsUser')->once()->with('brew list --formula | grep [email protected]')->andReturn('php');
swap(CommandLine::class, $cli);
$this->assertFalse(resolve(Brew::class)->installed('[email protected]'));

$cli = Mockery::mock(CommandLine::class);
$cli->shouldReceive('runAsUser')->once()->with('brew list | grep [email protected]')->andReturn('php
$cli->shouldReceive('runAsUser')->once()->with('brew list --formula | grep [email protected]')->andReturn('php
[email protected]
php7');
swap(CommandLine::class, $cli);
Expand Down Expand Up @@ -211,7 +211,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('runAsUser')->once()->with('brew list --formula | 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);
Expand All @@ -222,7 +222,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('runAsUser')->once()->with('brew list --formula | grep dnsmasq')->andReturn('dnsmasq');
$cli->shouldReceive('quietly')->once()->with('sudo brew services stop dnsmasq');
swap(CommandLine::class, $cli);
resolve(Brew::class)->stopService('dnsmasq');
Expand Down

0 comments on commit 3f0f157

Please sign in to comment.