spelling
[p5sagit/Distar.git] / lib / Distar.pm
index 51fd402..3e2dad9 100644 (file)
@@ -3,6 +3,9 @@ package Distar;
 use strictures 1;
 use base qw(Exporter);
 
+use Config;
+use File::Spec;
+
 our @EXPORT = qw(
   author manifest_include run_preflight
 );
@@ -14,13 +17,15 @@ sub import {
 
 sub author { our $Author = shift }
 
+our $Ran_Preflight;
+
 our @Manifest = (
   'lib' => '.pm',
   't' => '.t',
   't/lib' => '.pm',
   'xt' => '.t',
   'xt/lib' => '.pm',
-  '' => '.PL',
+  '' => qr{[^/]*\.PL},
   '' => qr{Changes|MANIFEST|README|META\.yml},
   'maint' => qr{[^.].*},
 );
@@ -50,18 +55,24 @@ sub write_manifest_skip {
 }
 
 sub run_preflight {
+  $Ran_Preflight = 1;
+
   system("git fetch");
 
-  for (scalar `make manifest 2>&1 >/dev/null`) {
-    $_ && die "make manifest changed:\n$_ Go check it and retry";
+  my $make = $Config{make};
+  my $null = File::Spec->devnull;
+
+  for (scalar `"$make" manifest 2>&1 >$null`) {
+    $_ && die "$make manifest changed:\n$_ Go check it and retry";
   }
 
   for (scalar `git status`) {
+    /^# On branch master/ || die "Not on master. EEEK";
     /Your branch is (behind|ahead of)/ && die "Not synced with upstream";
   }
 
   for (scalar `git diff`) {
-    length && die "Oustanding changes";
+    length && die "Outstanding changes";
   }
   my $ymd = sprintf(
     "%i-%02i-%02i", (localtime)[5]+1900, (localtime)[4]+1, (localtime)[3]
@@ -76,18 +87,19 @@ sub run_preflight {
 sub MY::postamble { <<'END'; }
 preflight:
        perl -IDistar/lib -MDistar -erun_preflight $(VERSION)
-upload: preflight $(DISTVNAME).tar$(SUFFIX)
+release: preflight
+       $(MAKE) disttest
+       rm -rf $(DISTVNAME)
+       $(MAKE) $(DISTVNAME).tar$(SUFFIX)
        cpan-upload $(DISTVNAME).tar$(SUFFIX)
-release: upload
        git commit -a -m "Release commit for $(VERSION)"
-       git tag release_$(VERSION) -m "release $(VERSION)"
+       git tag v$(VERSION) -m "release v$(VERSION)"
        git push --tags
        git push
 distdir: readmefile
 readmefile: create_distdir
        pod2text $(VERSION_FROM) >$(DISTVNAME)/README
-       $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{README} => q{README file (added by Distar)}}) } ' \
-         -e '    or print "Could not add README to MANIFEST: $${'\''@'\''}\n"' --
+       $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-readme-to-manifest
 END
 
 {
@@ -97,13 +109,13 @@ END
     ExtUtils::MakeMaker::WriteMakefile(
       LICENSE => 'perl',
       @_, AUTHOR => our $Author, ABSTRACT_FROM => $args{VERSION_FROM},
-      test => { TESTS => ($args{test}{TESTS}||'').' xt/*.t' },
+      test => { TESTS => ($args{test}{TESTS}||'t/*.t').' xt/*.t' },
     );
   }
 }
 
 END {
-  write_manifest_skip()
+  write_manifest_skip() unless $Ran_Preflight
 }
 
 1;