Skip to content

Commit

Permalink
Exclude certain stubs from publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
EsdertCO committed Aug 29, 2020
1 parent 3088af5 commit 0aaa1d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Console/Patch.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private function handleCookiePatching()
\file_put_contents($appConfigPath, $fileContents);

$middlewarePath = \config('laravel-stubs.patch.middleware_folder').'/VerifyCsrfToken.php';
$middleware = \file_get_contents(__DIR__.'/../stubs/cookies/middleware.stub');
$middleware = \file_get_contents(__DIR__.'/../stubs/cookies/cookiemiddleware.stub');
$fileContents = \file_get_contents($middlewarePath);
if (!Str::contains($fileContents, $middleware)) {
$use = "use Illuminate\Cookie\CookieValuePrefix;
Expand Down
9 changes: 8 additions & 1 deletion src/Console/Publish/PublishStubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

class PublishStubs extends Command
{
protected $exclude = [
'cookie.stub',
'cookiejar.stub',
'cookieserviceprovider.stub',
'cookiemiddleware.stub'
];
/**
* The name and signature of the console command.
*
Expand Down Expand Up @@ -40,7 +46,8 @@ public function handle()
foreach ($files as $file) {
$to = $stubsPath . '/' . $file->getFilename();
$from = $file->getPathName();
if (!file_exists($to) || $this->option('force')) {
if ((!file_exists($to) || $this->option('force')) &&
!\in_array($file->getFilename(), $this->exclude)) {
file_put_contents($to, file_get_contents($from));
}
}
Expand Down
File renamed without changes.

0 comments on commit 0aaa1d5

Please sign in to comment.