sub script_command_pack {
my ($self, $args) = @_;
+ $args = $self->call_parser($args => [
+ 'core-only' => \my $core_only,
+ ]);
+
my @modules = split /\r?\n/, $self->trace(args => $args);
my @packlists = $self->packlists_containing(\@modules);
$self->packlists_to_tree($base, \@packlists);
my $file = shift @$args;
- print $self->fatpack_file($file);
+ print $self->fatpack_file($file, $core_only);
}
sub script_command_trace {
sub script_command_file {
my ($self, $args) = @_;
+
+ $args = $self->call_parser($args => [
+ 'core-only' => \my $core_only,
+ ]);
+
my $file = shift @$args;
- print $self->fatpack_file($file);
+ print $self->fatpack_file($file, $core_only);
}
sub fatpack_file {
- my ($self, $file) = @_;
+ my ($self, $file, $core_only) = @_;
my $shebang = "";
my $script = "";
my %files;
$self->collect_files($_, \%files) for @dirs;
- return join "\n", $shebang, $self->fatpack_code(\%files), $script;
+ my $lib_reset =
+ "BEGIN { use Config; \@INC = \@Config{qw(privlibexp archlibexp sitelibexp sitearchexp)} }\n";
+
+ return join "\n", $shebang, ($core_only ? $lib_reset : ()), $self->fatpack_code(\%files), $script;
}
# This method can be overload in sub classes
my $fp = App::FatPacker->new;
my $temp_fh = File::Temp->new;
select $temp_fh;
-$fp->script_command_file;
+$fp->script_command_file([qw/--core-only/]);
print "1;\n";
select STDOUT;
close $temp_fh;
# make sure we don't pick up things from our created dir
chdir File::Spec->tmpdir;
+my $guts = do { local (@ARGV,$/) = "$temp_fh"; <> };
+like( $guts, qr/\QBEGIN { use Config\E/, "saw core-only preamble" );
+
# Packed, now try using it:
require $temp_fh;