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

Handle old, customized sample valet drivers more gracefully

This commit is contained in:
Matt Stauffer
2023-02-07 21:59:58 -05:00
parent 72804018cb
commit 15cf3fefaf
2 changed files with 68 additions and 1 deletions

View File

@@ -52,7 +52,19 @@ public function fixOldSampleValetDriver(): void
$samplePath = VALET_HOME_PATH.'/Drivers/SampleValetDriver.php';
if ($this->files->exists($samplePath)) {
if (! str_contains($this->files->get($samplePath), 'namespace')) {
$contents = $this->files->get($samplePath);
if (! str_contains($contents, 'namespace')) {
if ($contents !== $this->files->get(__DIR__.'/../stubs/Valet3SampleValetDriver.php')) {
warning('Existing SampleValetDriver.php has been customized.');
warning('Backing up at '.$samplePath.'.bak');
$this->files->putAsUser(
VALET_HOME_PATH . '/Drivers/SampleValetDriver.php.bak',
$contents
);
}
$this->files->putAsUser(
VALET_HOME_PATH.'/Drivers/SampleValetDriver.php',
$this->files->getStub('SampleValetDriver.php')
@@ -73,6 +85,10 @@ public function errorIfOldCustomDrivers(): void
}
foreach ($this->files->scanDir($driversPath) as $driver) {
if (! ends_with($driver, 'ValetDriver.php')) {
continue;
}
if (! str_contains($this->files->get($driversPath.'/'.$driver), 'namespace')) {
warning('Please make sure all custom drivers have been upgraded for Valet 4.');
exit;