Permalink
Browse files

run splice in eval {} to avoid build failure (#3)

  • Loading branch information...
1 parent 0e70353 commit 4d7afb1e0799dbfd63191e609d7a47715ef58544 @plicease committed May 15, 2014
Showing with 17 additions and 10 deletions.
  1. +17 −10 lib/Alien/MSYS.pm
View
@@ -138,35 +138,42 @@ sub msys_path ()
require File::Spec;
foreach my $dir (split /;/, $ENV{PATH})
{
- my $mingw_get = File::Spec->catfile($dir, 'mingw-get.exe');
- if(-x $mingw_get)
- {
+ my $path = eval {
+ my $mingw_get = File::Spec->catfile($dir, 'mingw-get.exe');
+ die 'no mingw-get.exe' unless -x $mingw_get;
my($volume, $dirs) = File::Spec->splitpath($mingw_get);
my @dirs = File::Spec->splitdir($dirs);
splice @dirs, -2;
push @dirs, qw( msys 1.0 bin );
my $path = File::Spec->catdir($volume, @dirs);
- return $path if -x File::Spec->catfile($path, 'sh.exe');
- }
+ die 'no sh.exe' unless -x File::Spec->catfile($path, 'sh.exe');
+ $path;
+ };
+ return $path unless $@;
}
foreach my $dir (qw( C:\MinGW\msys\1.0\bin ))
{
return $dir if -x File::Spec->catfile($dir, 'sh.exe');
}
-
- if(eval { require File::HomeDir; require Win32::Shortcut; 1 })
- {
+
+ my $path = eval {
+ require File::HomeDir;
+ require Win32::Shortcut;
my $lnk_name = File::Spec->catfile(File::HomeDir->my_desktop, 'MinGW Installer.lnk');
+ die "No MinGW Installer.lnk" unless -r $lnk_name;
my $lnk = Win32::Shortcut->new;
$lnk->Load($lnk_name);
my($volume, $dirs) = File::Spec->splitpath($lnk->{Path});
my @dirs = File::Spec->splitdir($dirs);
splice @dirs, -3;
push @dirs, qw( msys 1.0 bin );
my $path = File::Spec->catdir($volume, @dirs);
- return $path if -x File::Spec->catfile($path, 'sh.exe');
- }
+ die 'no sh.exe' unless -x File::Spec->catfile($path, 'sh.exe');
+ $path;
+ };
+
+ return $path unless $@;
# TODO: if they reinstall the Alien::MSYS dist to a different directory, this may break
my $dir = eval { File::Spec->catdir(dist_dir('Alien-MSYS'), qw( msys 1.0 bin )) };

0 comments on commit 4d7afb1

Please sign in to comment.