diff --git a/src/upload.raku b/src/upload.raku index 432190d..3a39a69 100755 --- a/src/upload.raku +++ b/src/upload.raku @@ -29,10 +29,10 @@ sub stylize($katla-output) { } # Renders the file at the given location to the temporary directory -sub render-idris-file($idr, $katla-config) { +sub render-idris-file($idr, $katla-config, $base-dir = "src/".IO) { say "Converting $idr"; # Figure out our file paths - my $source-file = IO::Path.new($idr, :CWD("src/".IO)).resolve; + my $source-file = IO::Path.new($idr, :CWD($base-dir)).resolve; my $ttm-file = IO::Path.new($idr, :CWD($build-path)).extension("ttm").resolve; my $out-file = IO::Path.new($idr, :CWD($dir)).extension("html").resolve; @@ -94,7 +94,7 @@ my method render-index(%index:) { } sub MAIN( - $project_dir?, #= Base directory of project to upload, defaults to %*CWD + $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", @@ -108,6 +108,10 @@ sub MAIN( my @idris-files = paths("src", :file(-> $a {$a.ends-with(".idr") || $a.ends-with(".md")})) .map: *.IO.relative("src/".IO); + # Find and collect all of our test files + my @test-files = + paths("test/src", :file(-> $a {$a.ends-with(".idr") || $a.ends-with(".md")})) + .map: *.IO.relative("test/src/".IO); # Clean if there is more than one ttc folder, easiest way to locate the # correct one @@ -118,6 +122,13 @@ sub MAIN( exit -1 unless run ; } + # Now do the same for the test directory + $ttc-path = "test/build/ttc".IO; + if !($ttc-path ~~ :e) || $ttc-path.dir.elems != 1 { + exit -1 unless run ; + exit -1 unless run ; + } + # find our ttc folder $build-path = "build/ttc/".IO.dir[0]; @@ -132,7 +143,17 @@ sub MAIN( %index.&add-path($idr, $out.relative($dir)) when $out ~~ IO; } - my $index = %index.&render-index(); + # Now repeat for the test directory + my %test-index = %(); + $build-path = "test/build/ttc/".IO.dir[0]; + for @test-files.hyper :batch(1) -> $idr { + my $out = render-idris-file $idr, $katla-config.IO, "test/src".IO; + %test-index.&add-path($idr, $out.relative($dir)) when $out ~~ IO; + } + + my %final-index = ("src" => %index, "test" => ("src" => %test-index)); + + my $index = %final-index.&render-index(); my $title = $*CWD.basename; $index = html-en head(Map,