Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Vendor publish improvement #30408

Merged
merged 1 commit into from Oct 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/Illuminate/Foundation/Console/VendorPublishCommand.php
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be just a local variable where it's used?


/**
* 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A newline could be here to improve readability.

$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.');
}
}