1. Diab Jerius
  2. Hg::Lib

Commits

Diab Jerius  committed 678df1e

use File::Which to find the hg command if it isn't specified.

  • Participants
  • Parent commits 5d4e381
  • Branches default

Comments (0)

Files changed (4)

File Build.PL

View file
  • Ignore whitespace
     },
 
     requires => {
+        'File::Which'              => 0,
         'Capture::Tiny'            => 0,
         'Exporter'                 => 0,
         'FileHandle'               => 0,

File lib/Hg/Lib.pm

View file
  • Ignore whitespace
 use 5.10.1;
 
 use Hg::Lib::Client;
-use Hg::Lib::Utils 'prep_cmd';
+use Hg::Lib::Utils qw[ prep_cmd find_hg ];
 
 use Capture::Tiny 'capture';
 use Type::Params qw[ compile ];
         configs  => delete $opts->{configs},
         encoding => delete $opts->{encoding} // {},
         env      => delete $opts->{env} // {},
-        hg       => delete $opts->{hg} // 'hg',
+        hg       => delete $opts->{hg} // find_hg(),
         path     => delete $opts->{dest},
         timeout  => delete $opts->{timeout},
         connect  => delete $opts->{connect},

File lib/Hg/Lib/Server/Pipe.pm

View file
  • Ignore whitespace
 use Types::Standard -all;
 use Type::Params;
 
+use Hg::Lib::Utils 'find_hg';
+
 use Hg::Lib::Exception ':aliases';
 
 use Hg::Lib::Types '-all';
 # path to hg executable; allow multiple components
 has hg => (
     is      => 'ro',
-    default => 'hg',
+    default => sub { find_hg() },
     isa     => StrList,
     coerce  => StrList->coercion,
 );

File lib/Hg/Lib/Utils.pm

View file
  • Ignore whitespace
 use boolean ':all';
 
 use base 'Exporter';
-our @EXPORT_OK = ( 'prep_cmd' );
+our @EXPORT_OK = ( qw[ prep_cmd find_hg ] );
 
 # prep commands for submission to server
 # prep_cmd( $cmd, \@pos, \%named )
     return \@cmd;
 }
 
+sub find_hg {
+
+    require File::Which;
+
+    return scalar File::Which::which( 'hg' );
+
+}
+
 1;