tracks/perl6/bin/exercise-gen.pl6 in trackler-2.1.0.36 vs tracks/perl6/bin/exercise-gen.pl6 in trackler-2.1.0.37
- old
+ new
@@ -21,13 +21,16 @@
exit;
}
}
for @exercises -> $exercise {
- say "Generating $exercise...";
my $exercise-dir = $base-dir.child("exercises/$exercise");
- next if (my $yaml = $exercise-dir.child('example.yaml')) !~~ :f;
+ if (my $yaml = $exercise-dir.child('example.yaml')) !~~ :f {
+ say "No example.yaml found for $exercise.";
+ next;
+ };
+ print "Generating $exercise... ";
my %data = load-yaml $yaml.slurp;
$_=.chomp when Str for @(%data.values);
my $cdata = $base-dir.child("x-common/exercises/$exercise/canonical-data.json");
@@ -39,10 +42,10 @@
create-file |<Example.pm6 module>;
%data<module_file> = %data<stub>;
create-file "{%data<exercise>}.pm6", 'module';
- say "$exercise generated.";
+ say 'Generated.';
sub create-file ($filename, $template) {
spurt (my $file = $exercise-dir.child($filename)),
Template::Mustache.render($base-dir.child("templates/$template.mustache").slurp, %data);
$file.chmod(0o755) if $template ~~ 'test';