From 37cebd9636d909cee6369b9471a9ea8703fbe167 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Fri, 4 Jun 2021 14:43:53 +0200 Subject: fix handle missing configfile --- bin/mkdocs-prep.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') 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; -- cgit v1.2.3