Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Illuminate/Foundation/Console/StubPublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class StubPublishCommand extends Command
*/
protected $signature = 'stub:publish
{--existing : Publish and overwrite only the files that have already been published}
{--force : Overwrite any existing files}';
{--force : Overwrite any existing files}
{--only= : Published stubs will be limited to files that start with the given value}';

/**
* The console command description.
Expand Down Expand Up @@ -83,6 +84,19 @@ public function handle()
realpath(__DIR__.'/../../Routing/Console/stubs/middleware.stub') => 'middleware.stub',
];

if ($this->option('only')) {
$stubs = array_filter(
$stubs,
fn ($name) => str_starts_with($name, strtolower($this->option('only'))),
);
}

if (count($stubs) === 0) {
$this->components->error('No stubs matched the given options.');

return self::FAILURE;
}

$this->laravel['events']->dispatch($event = new PublishingStubs($stubs));

foreach ($event->stubs as $from => $to) {
Expand Down