Skip to content

Commit

Permalink
Error on file-write errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayesh committed Apr 2, 2024
1 parent d1c5e4c commit 0891e2f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ private function saveManifests(array $data): void {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $folder));
}

is_writable()

$replacements = [
'%version%' => $this->version,
'%releasedate%' => $data['date'],
Expand All @@ -119,11 +121,15 @@ private function saveManifests(array $data): void {
'%versionmin%' => str_replace('.', '', $this->version),
];

foreach ($files as $file) {
$targetFile = self::BASE_PATH . '/' . $this->version . '/' . str_replace('(version)', $this->version, $file);
$file = file_get_contents(self::BASE_PATH . '/templates/' . $file);
$file = strtr($file, $replacements);
file_put_contents($targetFile, $file);
foreach ($files as $fileName) {
$targetFile = self::BASE_PATH . '/' . $this->version . '/' . str_replace('(version)', $this->version, $fileName);
$fileContents = file_get_contents(self::BASE_PATH . '/templates/' . $fileName);
$fileContents = strtr($fileContents, $replacements);
file_put_contents($targetFile, $fileContents);

if (!file_exists($targetFile)) {
throw new \RuntimeException('Unable to write to file: '. $targetFile);
}
}
}

Expand Down

0 comments on commit 0891e2f

Please sign in to comment.