Skip to content

Commit

Permalink
Make symlinking actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
akahn committed Dec 28, 2010
1 parent ceb8cf4 commit a681fda
Showing 1 changed file with 4 additions and 38 deletions.
42 changes: 4 additions & 38 deletions Rakefile
Expand Up @@ -6,51 +6,17 @@ desc 'Installs dotfiles from this distribution for the first time'
task :setup do

files = Dir.glob('*', File::FNM_DOTMATCH)
files = files - ['.', '..', '.git', 'Rakefile']

puts "Linking the following files:"
files = files - ['.', '..', '.git', 'Rakefile', '.Rakefile.swp']
files.map do |file|
puts file
File.expand_path(file)
end


files.each do |from|
from = File.expand_path(from)
to = File.expand_path(File.join('~', File.basename(from)))

puts " - " + [from, to].join(' -> ')
if File.exists?(to)
print " ! Target exists... "
if File.symlink? to
FileUtils.rm to
puts "as a symlink, removed"
else
print "as a normal file/directory, moving to #{File.basename(to)}~... "
toto = to + '~'

if File.exist? toto
print "already exists! r)emove, or s)kip? "
order = STDIN.gets.chomp

case order
when 'r'
print ' ! Removing... '
FileUtils.rm toto
when 's'
puts ' ! Okay, skipped '
next
else
puts " ! Invalid entry, so skipping"
next
end
end

FileUtils.mv to, toto
puts "Done!"
end
end

FileUtils.symlink(from, to)
puts "* Linking #{from} to #{to}."
FileUtils.ln_sf(from, to)
end
end

Expand Down

0 comments on commit a681fda

Please sign in to comment.