Skip to content

Commit

Permalink
Merge pull request #9 from butcherman/dev
Browse files Browse the repository at this point in the history
Add ability to Customize Stubs
  • Loading branch information
butcherman committed Nov 26, 2022
2 parents e4655e2 + 7151830 commit d2a9483
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/ArtisanDevCommandsServiceProvider.php
Expand Up @@ -30,5 +30,9 @@ public function boot()
Commands\MakeTrait::class,
Commands\MakeVueComponent::class,
]);

$this->publishes([
__DIR__.'/Stubs/' => base_path('stubs/dev_commands')
], 'stubs');
}
}
9 changes: 5 additions & 4 deletions src/Commands/MakePage.php
Expand Up @@ -47,12 +47,13 @@ public function handle()
// Get the stub file for the generator.
protected function getStub()
{
if($this->option('optionsApi'))
$stubName = $this->option('optionsApi') ? 'PageStub-Options.stub' : 'PageStub-Setup.stub';

if(file_exists(base_path('stubs/dev_commands/'.$stubName)))
{
$this->line('options api');
return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/PageStub-Options.stub');
return base_path('stubs/dev_commands/'.$stubName);
}

return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/PageStub-Setup.stub');
return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/'.$stubName);
}
}
5 changes: 5 additions & 0 deletions src/Commands/MakeTrait.php
Expand Up @@ -56,6 +56,11 @@ protected function getStubVariables($traitName)
// Get the stub file for the generator.
protected function getStub()
{
if(file_exists(base_path('stubs/dev_commands/TraitStub.stub')))
{
return base_path('stubs/dev_commands/TraitStub.stub');
}

return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/TraitStub.stub');
}

Expand Down
9 changes: 5 additions & 4 deletions src/Commands/MakeVueComponent.php
Expand Up @@ -47,12 +47,13 @@ public function handle()
// Get the stub file for the generator.
protected function getStub()
{
if($this->option('optionsApi'))
$stubName = $this->option('optionsApi') ? 'ComponentStub-Options.stub' : 'ComponentStub-Setup.stub';

if(file_exists(base_path('stubs/dev_commands/'.$stubName)))
{
$this->line('options api');
return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/ComponentStub-Options.stub');
return base_path('stubs/dev_commands/'.$stubName);
}

return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/ComponentStub-Setup.stub');
return base_path('vendor/butcherman/artisan-dev-commands/src/Stubs/'.$stubName);
}
}

0 comments on commit d2a9483

Please sign in to comment.