Skip to content

Commit

Permalink
Only update autoload_runtime.php when it changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek authored and fabpot committed Jun 20, 2023
1 parent ad2f6a1 commit 03e9c5d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Internal/ComposerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ public function updateAutoloadFile(): void
'%runtime_options%' => '['.substr(var_export($extra, true), 7, -1)." 'project_dir' => {$projectDir},\n]",
]);

file_put_contents(substr_replace($autoloadFile, '_runtime', -4, 0), $code);
// could use Composer\Util\Filesystem::filePutContentsIfModified once Composer 1.x support is dropped for this plugin
$path = substr_replace($autoloadFile, '_runtime', -4, 0);
$currentContent = @file_exists($path) ? @file_get_contents($path) : false;
if (false === $currentContent || $currentContent !== $code) {
file_put_contents($path, $code);
}
}

public static function getSubscribedEvents(): array
Expand Down

0 comments on commit 03e9c5d

Please sign in to comment.