Skip to content

Commit

Permalink
Remove existing symlink in case it already exists. (#6)
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone authored Aug 16, 2023
1 parent 611795f commit 46dcdd4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Listeners/AddAssetSymlinkFolders.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ public function handle(ServeCommandStarted $event): void
/** @var string $to */
$to = $pair['to'];

/** @var string $rootDirectory */
$rootDirectory = Str::beforeLast($to, '/');

if ($this->files->isDirectory($to)) {
if (is_link($to)) {
$this->files->delete($to);
} elseif ($this->files->isDirectory($to)) {
$this->files->deleteDirectory($to);
}

/** @var string $rootDirectory */
$rootDirectory = Str::beforeLast($to, '/');

if (! $this->files->isDirectory($rootDirectory)) {
$this->files->ensureDirectoryExists($rootDirectory);
}
Expand Down

0 comments on commit 46dcdd4

Please sign in to comment.