Automatically search parent directories for the ipkg

This commit is contained in:
Nathan McCarty 2025-02-14 23:01:44 -05:00
parent 1f4b8b3c03
commit dd1579607a
2 changed files with 21 additions and 12 deletions

View file

@ -33,12 +33,14 @@ class Test {
say $_.out.trim.lines.map(*.indent($indent-level + 2)) say $_.out.trim.lines.map(*.indent($indent-level + 2))
.join("\n"); .join("\n");
} }
if $_.err.trim { # say $_.err.elems;
say colored('stderr:', 'underline') # if $_.err.trim {
.indent($indent-level + 2); # say $_.err.trim.lines.elems;
say $_.err.trim.lines.map(*.indent($indent-level + 2)) # say colored('stderr:', 'underline')
.join("\n"); # .indent($indent-level + 2);
} # say $_.err.trim.lines.map(*.indent($indent-level + 2))
# .join("\n");
# }
return True; return True;
} }
} }
@ -143,5 +145,10 @@ sub scan-ipkg(IO::Path:D $ipkg --> PackageInfo:D) {
sub scan-packages(--> Array[PackageInfo:D]) is export { sub scan-packages(--> Array[PackageInfo:D]) is export {
my PackageInfo:D @ipkgs = my PackageInfo:D @ipkgs =
paths(:file(*.ends-with(".ipkg"))).map(*.IO.&scan-ipkg); paths(:file(*.ends-with(".ipkg"))).map(*.IO.&scan-ipkg);
# Check out the parents if we didn't find an ipkg
if @ipkgs {
return @ipkgs; return @ipkgs;
} else {
indir $*CWD.parent, {scan-packages};
}
} }

View file

@ -79,7 +79,8 @@ sub idris-run(*@cmd) is export {
my $err = $proc.err.slurp(:close); my $err = $proc.err.slurp(:close);
if !$proc || $out.contains("Error:") { if !$proc || $out.contains("Error:") {
IdrisError.new( IdrisError.new(
out => $out, err => $err, out => $out,
err => $err,
exit-code => $proc.exitcode, command => @cmd.Str) exit-code => $proc.exitcode, command => @cmd.Str)
.throw; .throw;
} }
@ -110,12 +111,13 @@ sub idris-exec($expr, $file, $output-type? = Unit) is export {
} }
} }
# Run the expression # Run the expression
my $proc = run 'build/exec/iutils_out', :out, :err; my $proc = run 'build/exec/iutils_out', :out, :!err;
my $out = $proc.out.slurp(:close); my $out = $proc.out.slurp();
my $err = $proc.err.slurp(:close); # my $err = $proc.err.slurp();
unless $proc { unless $proc {
ExpressionError.new( ExpressionError.new(
out => $out, err => $err, out => $out,
# err => $err,
exit-code => $proc.exitcode, expr => $expr exit-code => $proc.exitcode, expr => $expr
).throw; ).throw;
} }