aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;