Skip to content

Commit

Permalink
Publish the files
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 10, 2024
1 parent 9ae61c9 commit f21a9d9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/framework/src/Console/Commands/PublishViewsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Hyde\Console\Commands;

use Hyde\Console\Concerns\Command;
use Hyde\Facades\Filesystem;
use Hyde\Foundation\Providers\ViewServiceProvider;
use Hyde\Hyde;
use Illuminate\Support\Collection;
Expand Down Expand Up @@ -136,10 +137,16 @@ protected function handleInteractivePublish(): void
// Now we need to prompt the user for which files to publish
$selectedFiles = $this->promptForFiles($files, basename($target));

$this->infoComment(sprintf("Selected files [%s]\n", collect($selectedFiles)->map(fn (string $file): string => Str::after($file, basename($source).'/'))->implode(', ')));

// Now we filter the files to only include the selected ones
$selectedFiles = $files->filter(fn (string $file): bool => in_array($file, $selectedFiles));

// Now we need to publish the selected files
foreach ($selectedFiles as $source => $target) {
Filesystem::ensureDirectoryExists(dirname($target));
Filesystem::copy($source, $target);
}

$this->infoComment(sprintf("Published files [%s]", collect($selectedFiles)->map(fn (string $file): string => Str::after($file, basename($source).'/'))->implode(', ')));
}

protected function promptForFiles(Collection $files, string $baseDir): array
Expand Down

0 comments on commit f21a9d9

Please sign in to comment.