Skip to content

Commit

Permalink
Improvements to Artisan's 'vendor:publish' command.
Browse files Browse the repository at this point in the history
  • Loading branch information
vaughany authored and yakryder committed Oct 23, 2019
1 parent 4ab899a commit 76b39de
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/Illuminate/Foundation/Console/VendorPublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ class VendorPublishCommand extends Command
*/
protected $tags = [];

/**
* Boolean describing the status of files. Initially set to false, it changes
* to true if any file is successfully published.
*
* @var bool
*/
protected $published;

/**
* The console command signature.
*
Expand Down Expand Up @@ -61,6 +69,8 @@ public function __construct(Filesystem $files)
parent::__construct();

$this->files = $files;

$this->published = false;
}

/**
Expand Down Expand Up @@ -159,6 +169,13 @@ protected function publishTag($tag)
{
foreach ($this->pathsToPublish($tag) as $from => $to) {
$this->publishItem($from, $to);

$this->published = true;
}
if ($this->published) {
$this->info('Publishing complete.');
} else {
$this->error('Nothing to publish.');
}
}

Expand Down Expand Up @@ -208,6 +225,8 @@ protected function publishFile($from, $to)
$this->files->copy($from, $to);

$this->status($from, $to, 'File');
} else {
$this->didntCopyStatus($from, $to, 'File');
}
}

Expand Down Expand Up @@ -272,4 +291,21 @@ protected function status($from, $to, $type)

$this->line('<info>Copied '.$type.'</info> <comment>['.$from.']</comment> <info>To</info> <comment>['.$to.']</comment>');
}

/**
* Write a 'didn't copy' status message to the console.
*
* @param string $from
* @param string $to
* @param string $type
* @return void
*/
protected function didntCopyStatus($from, $to, $type)
{
$from = str_replace(base_path(), '', realpath($from));

$to = str_replace(base_path(), '', realpath($to));

$this->warn('Did not copy '.strtolower($type).' ['.$from.'] to ['.$to.'] as file already exists and "--force" was not specified.');
}
}

0 comments on commit 76b39de

Please sign in to comment.