Return early so we can reduce nesting of conditionals

This commit is contained in:
Jack Nagel 2014-03-27 18:39:54 -05:00
parent ed0be26c77
commit 4e918666d7

View File

@ -291,11 +291,13 @@ class Pathname
# perhaps confusingly, this Pathname object becomes the symlink pointing to
# the src paramter.
def make_relative_symlink src
self.dirname.mkpath
Dir.chdir self.dirname do
dirname.mkpath
dirname.cd do
# NOTE only system ln -s will create RELATIVE symlinks
quiet_system 'ln', '-s', src.relative_path_from(self.dirname), self.basename
if not $?.success?
return if quiet_system("ln", "-s", src.relative_path_from(dirname), basename)
end
if symlink? && exist?
raise <<-EOS.undent
Could not symlink file: #{src}
@ -334,8 +336,6 @@ class Pathname
EOS
end
end
end
end
def / that
join that.to_s