Last active
December 25, 2015 13:39
-
-
Save Songmu/6985183 to your computer and use it in GitHub Desktop.
上手く動かない君
This file contains hidden or 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
| #!/usr/bin/env perl | |
| use 5.016; | |
| use strict; | |
| use warnings; | |
| use utf8; | |
| use autodie; | |
| use File::Path qw/mkpath/; | |
| use Carton::CLI; | |
| use Module::Metadata; | |
| use Config; | |
| package | |
| Ore::Guard { | |
| sub new { | |
| my ($class, $handler) = @_; | |
| bless $handler, $class; | |
| } | |
| sub DESTROY { | |
| my $self = shift; | |
| $self->(); | |
| } | |
| } | |
| my $cmd_install = Carton::CLI->can('cmd_install'); | |
| { | |
| no warnings 'redefine'; | |
| no strict 'refs'; | |
| *{'Carton::CLI::cmd_install'} = sub { | |
| my $content = do { | |
| my $cpanminus_path = Module::Metadata->find_module_by_name("App::cpanminus::fatscript") | |
| or die "Can't locate App::cpanminus::fatscript."; | |
| local $/; | |
| open my $fh, '<', $cpanminus_path; | |
| <$fh> | |
| }; | |
| my $tmp_cpanminus = 'extlib/lib/perl5/App/cpanminus/fatscript.pm'; | |
| mkpath 'extlib/lib/perl5/App/cpanminus/'; | |
| open my $fh, '>', 'extlib/lib/perl5/App/cpanminus/fatscript.pm'; | |
| print $fh $content; | |
| my $guard = Ore::Guard->new(sub { unlink $tmp_cpanminus }); | |
| my $path = 'local'; | |
| local @INC = @Config{qw(privlibexp archlibexp)}; | |
| my @inc = map {($_, "$_/$Config{archname}")} ('extlib/lib/perl5', "$path/lib/perl5"); | |
| unshift @INC, @inc; | |
| goto $cmd_install; | |
| }; | |
| } | |
| Carton::CLI->new->run(@ARGV); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment