forked from miyagawa/cpanminus
/
dzil
49 lines (38 loc) · 1.33 KB
/
dzil
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name 'dzil';
description 'Build dzil based distributions from git/svn repositories';
author 'Tatsuhiko Miyagawa';
api_version 0.1;
hook pre_configure => sub {
my $args = shift;
if (-e "dist.ini" && !-e 'Makefile.PL' && !-e 'Build.PL') {
$args->{app}->chat("Found dist.ini - build this distribution using dzil");
push @{$args->{deps}}, 'Dist::Zilla', 0;
require Config::INI::Reader;
my $hash = Config::INI::Reader->read_file("dist.ini");
while (my($k, $v) = each %{$hash->{_}}) {
$args->{meta}->{$k} = $v;
}
for my $key (keys %$hash) {
next if $key eq '_';
$key = (split m{\s*/\s*}, $key)[0];
$key =~ s/^\s*//;
if ($key =~ s/^\@//) {
push @{$args->{deps}}, "Dist::Zilla::PluginBundle::$key", 0;
} elsif ($key =~ s/^=//) {
push @{$args->{deps}}, $key, 0;
} else {
push @{$args->{deps}}, "Dist::Zilla::Plugin::$key", 0;
}
}
}
};
hook build_dist => sub {
my $args = shift;
if (-e "dist.ini" && !-e 'Makefile.PL' && !-e 'Build.PL') {
$args->{app}->chat("Running dzil install");
return sub {
system "dzil", "install", "--install-command=$^X -S cpanm .";
};
}
return;
};