-
-
Save ugexe/017672ef39723ff6e33744d08a854872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
has %!known; # cache `provides` of META6 when available | |
method !matching-file(CompUnit::DependencySpecification $spec) { | |
if $spec.from eq 'Perl6' { | |
my $name = $spec.short-name; | |
return %!loaded{$name} if %!loaded{$name}:exists; | |
my $base := $!prefix.child($name.subst(:g, "::", $*SPEC.dir-sep) ~ '.').Str; | |
return $base if %seen{$base}:exists; | |
my $meta = $!prefix.child('META6.json'); | |
%!known //= try { | |
Rakudo::Internals::JSON.from-json($meta.slurp).hash<provides>; | |
CATCH { | |
when JSONException { | |
fail "Invalid JSON found in META6.json"; | |
} | |
} | |
}; | |
my $found = %!known{$name}:exists && %!known{$name}.IO.f | |
?? %!known{$name}.IO | |
!! %extensions<Perl6>.map({ $base ~ $extension }).first(*.IO.e).IO; | |
return $base, $found if $found; | |
} | |
False | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment