aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2021-06-04 14:43:53 +0200
committerJonas Smedegaard <dr@jones.dk>2021-06-04 14:43:53 +0200
commit37cebd9636d909cee6369b9471a9ea8703fbe167 (patch)
tree6fad2c69f77ab5c8ecde9f37dad314de4efc7959 /bin
parent22faacd38476f7af50cdafc5584baf8fb971a4bc (diff)
fix handle missing configfile
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mkdocs-prep.pl9
1 files changed, 6 insertions, 3 deletions
diff --git a/bin/mkdocs-prep.pl b/bin/mkdocs-prep.pl
index 96bba69..fdb4c30 100755
--- a/bin/mkdocs-prep.pl
+++ b/bin/mkdocs-prep.pl
@@ -49,8 +49,10 @@ is replaced (including brackets) with corresponding string.
my ( $infile, $outfile ) = @ARGV;
@ARGV = undef;
-my $config = Config::Tiny->new;
-$config = Config::Tiny->read( 'site.mk', 'utf8' );
+my $cfgfile = path('site.mk');
+my $config = $cfgfile->exists
+ ? Config::Tiny->read( $cfgfile, 'utf8' )
+ : Config::Tiny->new;
my $config_has_changed;
my $content = path($infile)->slurp_utf8;
@@ -78,7 +80,8 @@ my $template = $compiler->compile($content);
path($outfile)->spew_utf8( $template->render( $config->{_} ) );
-$config->write( 'site.mk', 'utf8' )
+$cfgfile->touch;
+$config->write( $cfgfile, 'utf8' )
if $config_has_changed;
1;