diff options
author | Jonas Smedegaard <dr@jones.dk> | 2021-06-04 14:43:53 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2021-06-04 14:43:53 +0200 |
commit | 37cebd9636d909cee6369b9471a9ea8703fbe167 (patch) | |
tree | 6fad2c69f77ab5c8ecde9f37dad314de4efc7959 /bin/mkdocs-prep.pl | |
parent | 22faacd38476f7af50cdafc5584baf8fb971a4bc (diff) |
fix handle missing configfile
Diffstat (limited to 'bin/mkdocs-prep.pl')
-rwxr-xr-x | bin/mkdocs-prep.pl | 9 |
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; |