mirror of
https://github.com/laravel/valet.git
synced 2026-02-04 08:10:07 +01:00
Clean up NullWriter; drop legacy config check
This commit is contained in:
@@ -49,14 +49,6 @@ public function uninstall(): void
|
||||
public function createConfigurationDirectory(): void
|
||||
{
|
||||
$this->files->ensureDirExists(preg_replace('~/valet$~', '', VALET_HOME_PATH), user());
|
||||
|
||||
$oldPath = posix_getpwuid(fileowner(__FILE__))['dir'].'/.valet';
|
||||
|
||||
if ($this->files->isDir($oldPath)) {
|
||||
rename($oldPath, VALET_HOME_PATH);
|
||||
$this->prependPath(VALET_HOME_PATH.'/Sites');
|
||||
}
|
||||
|
||||
$this->files->ensureDirExists(VALET_HOME_PATH, user());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,25 +18,12 @@ public function __construct(public Filesystem $files)
|
||||
*/
|
||||
public function onEveryRun(): void
|
||||
{
|
||||
$this->relocateOldConfig();
|
||||
$this->pruneMissingDirectories();
|
||||
$this->pruneSymbolicLinks();
|
||||
$this->fixOldSampleValetDriver();
|
||||
$this->errorIfOldCustomDrivers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Relocate config dir to ~/.config/valet/ if found in old location.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function relocateOldConfig()
|
||||
{
|
||||
if (is_dir(VALET_LEGACY_HOME_PATH) && ! is_dir(VALET_HOME_PATH)) {
|
||||
Configuration::createConfigurationDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prune all non-existent paths from the configuration.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
// Allow bypassing these checks if using Valet in a non-CLI app
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
define('VALET_LOOPBACK', '127.0.0.1');
|
||||
define('VALET_SERVER_PATH', realpath(__DIR__.'/../../server.php'));
|
||||
define('VALET_LEGACY_HOME_PATH', $_SERVER['HOME'].'/.valet');
|
||||
|
||||
define('BREW_PREFIX', (new CommandLine())->runAsUser('printf $(brew --prefix)'));
|
||||
|
||||
@@ -34,9 +33,9 @@
|
||||
* Set or get a global console writer.
|
||||
*
|
||||
* @param null|OutputInterface $writer
|
||||
* @return OutputInterface Or anonymous class
|
||||
* @return OutputInterface|\NullWriter|null
|
||||
*/
|
||||
function writer(?OutputInterface $writer = null)/*: OutputInterface*/
|
||||
function writer(?OutputInterface $writer = null): OutputInterface|\NullWriter|null
|
||||
{
|
||||
$container = Container::getInstance();
|
||||
|
||||
@@ -48,7 +47,9 @@ function writer(?OutputInterface $writer = null)/*: OutputInterface*/
|
||||
return $container->make('writer');
|
||||
}
|
||||
|
||||
return Container::getInstance()->instance('writer', $writer);
|
||||
Container::getInstance()->instance('writer', $writer);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,6 @@ public function test_configuration_directory_is_created_if_it_doesnt_exist()
|
||||
$files = Mockery::mock(Filesystem::class.'[ensureDirExists,isDir]');
|
||||
$files->shouldReceive('ensureDirExists')->once()->with(preg_replace('~/valet$~', '', VALET_HOME_PATH), user());
|
||||
$files->shouldReceive('ensureDirExists')->once()->with(VALET_HOME_PATH, user());
|
||||
$files->shouldReceive('isDir')->once();
|
||||
swap(Filesystem::class, $files);
|
||||
resolve(Configuration::class)->createConfigurationDirectory();
|
||||
}
|
||||
|
||||
@@ -6,12 +6,14 @@ trait UsesNullWriter
|
||||
{
|
||||
public function setNullWriter()
|
||||
{
|
||||
Container::getInstance()->instance('writer', new class
|
||||
Container::getInstance()->instance('writer', new NullWriter);
|
||||
}
|
||||
}
|
||||
|
||||
class NullWriter
|
||||
{
|
||||
public function writeLn($msg)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user