Skip to content

Commit 2d78684

Browse files
committed
Detect empty content before running
1 parent 5b114d3 commit 2d78684

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

bin/bump.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
function read_version( string $file ): string {
1616
$contents = file_get_contents( $file );
1717

18+
if ( false === $contents ) {
19+
throw new RuntimeException( "Could not read file: {$file}" );
20+
}
21+
1822
if ( 1 === preg_match( "/PLUGIN_VERSION', '([^']+)'/", $contents, $matches ) ) {
1923
return $matches[1];
2024
}
@@ -70,6 +74,10 @@ function bump_version( string $version, string $type ): string {
7074
function update_version( string $file, string $old_version, string $new_version ): void {
7175
$contents = file_get_contents( $file );
7276

77+
if ( false === $contents ) {
78+
throw new RuntimeException( "Could not read file: {$file}" );
79+
}
80+
7381
$contents = str_replace(
7482
"PLUGIN_VERSION', '{$old_version}'",
7583
"PLUGIN_VERSION', '{$new_version}'",

0 commit comments

Comments
 (0)