From: Matt S Trout Date: Thu, 18 Oct 2012 20:35:24 +0000 (+0000) Subject: improvements to generate command X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FApp-SCS.git;a=commitdiff_plain;h=b9125661c7e95abaccfd54fd195cf72f8b8237e8 improvements to generate command --- diff --git a/lib/App/SCS/Plugin/Generate.pm b/lib/App/SCS/Plugin/Generate.pm index f765f76..d36568a 100644 --- a/lib/App/SCS/Plugin/Generate.pm +++ b/lib/App/SCS/Plugin/Generate.pm @@ -25,14 +25,22 @@ sub run_command_generate (dir=s;host=s;only=s) { $dir->mkpath; my $prefix = 'http://'.($opt->{host} || $self->host); if (my $only = $opt->{only}) { - my $re = qr/^\Q${only}/; + my $re = qr/^${only}/; @all_paths = grep /$re/, @all_paths; } + my @fail; foreach my $path (@all_paths) { warn "Generating ${path}\n"; + my $res = $self->app->web->run_test_request(GET => "${prefix}${path}"); + + unless ($res->is_success) { + warn "ERROR on ${path}\n"; + push @fail, [ $path, $res ]; + next; + } + my $dir = $dir->catdir($path); $dir->mkpath; - my $res = $self->app->web->run_test_request(GET => "${prefix}${path}"); # text/html -> html # application/atom+xml -> atom my ($ext) = $res->content_type =~ m{\/(\w+)} @@ -41,6 +49,15 @@ sub run_command_generate (dir=s;host=s;only=s) { ." for path ${path}"; $dir->catfile("index.${ext}")->print($res->content); } + warn "\nERRORS GENERATING PAGES:\n"; + foreach my $fail (@fail) { + my ($path, $res) = @$fail; + warn "\nFailed to generate ${path}:\n"; + my $error = $res->content||''; + $error =~ s/^/ /mg; + $error .= "\n" unless $error =~ /\n\Z/; + warn $error; + } } sub run_command_staticserver {