Skip to content

Commit

Permalink
Replace command name before parent
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed Mar 18, 2024
1 parent a9ae4bf commit f845ec5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Console/Commands/Make/MakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ class MakeCommand extends ConsoleMakeCommand

protected function replaceClass($stub, $name)
{
$stub = parent::replaceClass($stub, $name);
$module = $this->module();

if ($module && (! $this->option('command') || 'command:name' === $this->option('command'))) {
$cli_name = Str::of($name)->classBasename()->kebab();

$find = [
"'command:name'",
"'app:{$cli_name}'",
"command:name",
"app:{$cli_name}",
];

$stub = str_replace($find, "'{$module->name}:{$cli_name}'", $stub);
$stub = str_replace($find, "{$module->name}:{$cli_name}", $stub);
}

return $stub;
return parent::replaceClass($stub, $name);
}
}

0 comments on commit f845ec5

Please sign in to comment.