diff options
| author | Jack Nagel | 2014-03-18 19:03:25 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2014-03-18 19:03:25 -0500 | 
| commit | 53bd6eace92dc81c03e2c63f2e7f2ccbcac14420 (patch) | |
| tree | 92b2c6541f835e7d67f99a3f0f6802a32282da15 | |
| parent | 8393f40bdb466026fcb95671afae3ff652e86789 (diff) | |
| download | homebrew-53bd6eace92dc81c03e2c63f2e7f2ccbcac14420.tar.bz2 | |
Make relative symlinks in Pathname#install_symlink
Closes #27672.
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 10 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_pathname.rb | 2 | 
2 files changed, 5 insertions, 7 deletions
| diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 9e1e809db..e94748431 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -79,14 +79,10 @@ class Pathname      end    end -  def install_symlink_p src, new_basename = nil -    if new_basename.nil? -      dst = self+File.basename(src) -    else -      dst = self+File.basename(new_basename) -    end +  def install_symlink_p src, new_basename=src +    dst = join File.basename(new_basename)      mkpath -    FileUtils.ln_s src.to_s, dst.to_s +    FileUtils.ln_s Pathname(src).relative_path_from(dst.parent), dst    end    protected :install_symlink_p diff --git a/Library/Homebrew/test/test_pathname.rb b/Library/Homebrew/test/test_pathname.rb index 37b85a07d..03e4df54c 100644 --- a/Library/Homebrew/test/test_pathname.rb +++ b/Library/Homebrew/test/test_pathname.rb @@ -194,6 +194,8 @@ class PathnameExtensionTests < Test::Unit::TestCase        assert((@dst+'bin').directory?)        assert((@dst+'bin/a.txt').exist?)        assert((@dst+'bin/b.txt').exist?) + +      assert((@dst+'bin').readlink.relative?)      end    end | 
