Last active
July 7, 2018 01:14
-
-
Save ugexe/5438a940e4f780f96a61860e327529c8 to your computer and use it in GitHub Desktop.
Perl6 post-install hook
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
# PERL6LIB="/Users/ugexe/repos/CompUnit-Repository-InstallationWithHook/lib"\ | |
# perl6 -I /Users/ugexe/repos/zef /Users/ugexe/repos/zef/bin/zef\ | |
# -to="CompUnit::Repository::InstallationWithHook#/Users/ugexe/.rakudobrew/moar-blead-master/install/share/perl6/site"\ | |
# install /Users/ugexe/repos/zef | |
class CompUnit::Repository::InstallationWithHook is CompUnit::Repository::Installation { | |
method short-id { 'inst-with-hook' } | |
method path-spec { $.short-id ~ '#' } | |
multi method install(Distribution $dist) { | |
return unless my $result = callsame(); | |
# install was ok, but doesn't return a Distribution that maps to the new location so we need to fetch one that does. | |
my $curi = CompUnit::Repository::Installation.new(prefix => $.prefix.IO.absolute); | |
my $dep-spec = CompUnit::DependencySpecification.new( | |
short-name => $dist.meta<name>, | |
version-matcher => True, | |
api-matcher => True, | |
auth-matcher => $dist.meta<auth>, | |
); | |
my $installed-dist = $curi.resolve($dep-spec); | |
my %bin-files = $installed-dist.meta<files>.hash.grep(*.key.starts-with('bin/')); | |
for $installed-dist.meta<files>.hash { | |
my $name-path = .key; | |
my $file = .value; | |
next unless $name-path.starts-with('bin/'); | |
say "===> $name-path -> " ~ $.prefix.add("resources/$file").absolute; | |
say $dist.content($name-path).open.slurp(:close); | |
} | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment