Skip to content

Commit

Permalink
fix: unable to remove lazy loaded commands
Browse files Browse the repository at this point in the history
  • Loading branch information
alpha0010 committed Apr 25, 2024
1 parent 1c44f0c commit beb047f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Kernel.php
Expand Up @@ -205,9 +205,18 @@ function ($artisan) use ($toRemoveCommands) {
* command class.
*/
Artisan::starting(
function ($artisan) use ($commands) {
function ($artisan) use ($commands, $toRemoveCommands) {
$artisan->resolveCommands($commands->toArray());

$reflectionClass = new ReflectionClass(Artisan::class);
$property = $reflectionClass->getProperty('commandMap');
$commandMap = collect($property->getValue($artisan))
->filter(
fn ($command) => ! in_array($command, $toRemoveCommands, true)
)
->toArray();
$property->setValue($artisan, $commandMap);

$artisan->setContainerCommandLoader();
}
);
Expand Down

0 comments on commit beb047f

Please sign in to comment.