Preserve artisan file permissions
This commit is contained in:
@@ -150,12 +150,21 @@ class ArtisanPatcher
|
||||
private function write(string $contents): void
|
||||
{
|
||||
$temporaryPath = $this->artisanPath.'.british-artisan.tmp';
|
||||
$permissions = fileperms($this->artisanPath);
|
||||
|
||||
if ($permissions === false) {
|
||||
throw new RuntimeException('Could not read the artisan file permissions.');
|
||||
}
|
||||
|
||||
try {
|
||||
if (file_put_contents($temporaryPath, $contents, LOCK_EX) === false) {
|
||||
throw new RuntimeException('Could not write the temporary artisan file.');
|
||||
}
|
||||
|
||||
if (! chmod($temporaryPath, $permissions & 0777)) {
|
||||
throw new RuntimeException('Could not preserve the artisan file permissions.');
|
||||
}
|
||||
|
||||
if (! rename($temporaryPath, $this->artisanPath)) {
|
||||
throw new RuntimeException('Could not replace the artisan file.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user