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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user