No longer require katla config to be in project

This commit is contained in:
Nathan McCarty 2024-12-21 20:17:20 +00:00
parent a4dcd397c9
commit 35ba371711

View file

@ -29,7 +29,7 @@ sub stylize($katla-output) {
}
# Renders the file at the given location to the temporary directory
sub render-idris-file($idr) {
sub render-idris-file($idr, $katla-config) {
say "Converting $idr";
# Figure out our file paths
my $source-file = IO::Path.new($idr, :CWD("src/".IO)).resolve;
@ -40,9 +40,17 @@ sub render-idris-file($idr) {
return unless $ttm-file ~~ :e;
# Generate the html
# TODO: Stop relying on the config for now and just colorize it in regexs
my $katla = run <katla html --config>, "katla/katla.dhall",
my $katla = run <katla html --config>, $katla-config,
$source-file, $ttm-file, :out;
my $contents = $katla.out.slurp :close;
say $source-file;
say $ttm-file;
say $katla-config;
if $katla.exitcode != 0 {
say "Katla Error:";
say $contents;
exit $katla.exitcode;
}
$contents = stylize $contents;
# Make sure the directory exists and write the contents to it
$out-file.dirname.IO.mkdir;
@ -96,6 +104,8 @@ my method render-index(%index:) {
sub MAIN(
$project_dir?, #= Base directory of project to upload, defaults to %*CWD
$dest_dir?, #= Destination directory on the remote
$katla-config = #= Configuration file to pass to katla
"/home/nathan/Projects/Idris/.scripts/src/katla.dhall",
) {
# cd to the projet directory if needed
if $project_dir ~~ Str {
@ -125,7 +135,7 @@ sub MAIN(
# temporary directory
my %index = %();
for @idris-files.hyper :batch(1) -> $idr {
my $out = render-idris-file $idr;
my $out = render-idris-file $idr, $katla-config.IO;
%index.&add-path($idr, $out.relative($dir)) when $out ~~ IO;
}