diff --git a/lib/App/Sqitch/Config.pm b/lib/App/Sqitch/Config.pm index 832fba37b..893c829f6 100644 --- a/lib/App/Sqitch/Config.pm +++ b/lib/App/Sqitch/Config.pm @@ -4,7 +4,6 @@ use v5.10.1; use Moose; use strict; use warnings; -use Config; use Path::Class; use Carp; use utf8; @@ -17,6 +16,8 @@ has '+confname' => ( default => 'sqitch.conf', ); +my $SYSTEM_DIR = undef; + sub user_dir { require File::HomeDir; my $hd = File::HomeDir->my_home or croak( @@ -26,7 +27,10 @@ sub user_dir { } sub system_dir { - dir $Config{prefix}, 'etc', 'sqitch'; + dir $SYSTEM_DIR || do { + require Config; + $Config::Config{prefix}, 'etc', 'sqitch'; + }; } sub system_file { diff --git a/priv/Module/Build/Sqitch.pm b/priv/Module/Build/Sqitch.pm index ac6b84cfe..7aef7438a 100644 --- a/priv/Module/Build/Sqitch.pm +++ b/priv/Module/Build/Sqitch.pm @@ -37,4 +37,20 @@ sub process_etc_files { } } +sub process_pm_files { + my $self = shift; + my $ret = $self->SUPER::process_pm_files(@_); + my $pm = File::Spec->catfile(qw(blib lib App Sqitch Config.pm)); + my $etc = $self->_path_to('etc'); + + $self->do_system( + $self->perl, + '-i', '-pe', + qq{s{my \\\$SYSTEM_DIR = undef}{my \\\$SYSTEM_DIR = q{$etc}}}, + $pm, + ); + + return $ret; +} + 1; diff --git a/t/add_step.t b/t/add_step.t index f7b8a3970..1d3a74e2a 100644 --- a/t/add_step.t +++ b/t/add_step.t @@ -141,7 +141,7 @@ is $add_step->template_directory, undef, 'Default dir should be undef'; MOCKCONFIG: { my $config_mock = Test::MockModule->new('App::Sqitch::Config'); - $config_mock->mock(system_dir => 'nonexistent'); + $config_mock->mock(system_dir => Path::Class::dir('nonexistent')); for my $script (qw(deploy revert test)) { my $with = "with_$script"; ok $add_step->$with, "$with should be true by default";