move wrapper building loop into Wrapper.pm
authorJoey Hess <joey@kitenet.net>
Sat, 24 Jul 2010 21:33:59 +0000 (17:33 -0400)
committerJoey Hess <joey@kitenet.net>
Sat, 24 Jul 2010 21:33:59 +0000 (17:33 -0400)
IkiWiki/Wrapper.pm
ikiwiki.in

index bd134c9a35c2fa87eef5a505e43984bdc26cc1d5..927368fae964d678ab04aa866154b61677f80176 100644 (file)
@@ -8,6 +8,26 @@ use File::Spec;
 use Data::Dumper;
 use IkiWiki;
 
+sub gen_wrappers () {
+       debug(gettext("generating wrappers.."));
+       my %origconfig=(%config);
+       foreach my $wrapper (@{$config{wrappers}}) {
+               %config=(%origconfig, %{$wrapper});
+               $config{verbose}=$config{setupverbose}
+                       if exists $config{setupverbose};
+               $config{syslog}=$config{setupsyslog}
+                       if exists $config{setupsyslog};
+               delete @config{qw(setupsyslog setupverbose wrappers genwrappers rebuild)};
+               checkconfig();
+               if (! $config{cgi} && ! $config{post_commit} &&
+                   ! $config{test_receive}) {
+                       $config{post_commit}=1;
+               }
+               gen_wrapper();
+       }
+       %config=(%origconfig);
+}
+
 sub gen_wrapper () {
        $config{srcdir}=File::Spec->rel2abs($config{srcdir});
        $config{destdir}=File::Spec->rel2abs($config{destdir});
index aa333793836455eb558f9151e43e96d35d5abb63..bcda2469b515c33a8df91536da895f28841574b3 100755 (executable)
@@ -163,24 +163,8 @@ sub main () {
                    ! $config{clean} &&
                    ((! $config{refresh} && ! $config{post_commit})
                     || $config{genwrappers})) {
-                       debug(gettext("generating wrappers.."));
                        require IkiWiki::Wrapper;
-                       my %origconfig=(%config);
-                       foreach my $wrapper (@{$config{wrappers}}) {
-                               %config=(%origconfig, %{$wrapper});
-                               $config{verbose}=$config{setupverbose}
-                                       if exists $config{setupverbose};
-                               $config{syslog}=$config{setupsyslog}
-                                       if exists $config{setupsyslog};
-                               delete @config{qw(setupsyslog setupverbose wrappers genwrappers rebuild)};
-                               checkconfig();
-                               if (! $config{cgi} && ! $config{post_commit} &&
-                                   ! $config{test_receive}) {
-                                       $config{post_commit}=1;
-                               }
-                               gen_wrapper();
-                       }
-                       %config=(%origconfig);
+                       gen_wrappers();
                }
                
                # setup implies a wiki rebuild by default