Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Build system config dir into Config.

  • Loading branch information...
commit bf00ff9fca33c21c6a3642cea93557d24a2c2c1c 1 parent fd2a7ce
@theory authored
View
8 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 {
View
16 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;
View
2  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";
Please sign in to comment.
Something went wrong with that request. Please try again.