Skip to content

Commit

Permalink
Add a list of directories not to symlink with dots
Browse files Browse the repository at this point in the history
  • Loading branch information
wsc committed May 8, 2011
1 parent e7295ce commit 606362b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
# Adapted from Ryan Bates's dotfiles rakefile
# https://github.com/ryanb/dotfiles

require 'rake'
require 'fileutils'

desc "install dotfiles"
IGNORES = %w{Rakefile README.md LICENSE}
NO_DOTS = %w{bin}

task :default => :install

desc "install dotfiles"
task :install do
Dir['*'].each do |file|
next if %w[Rakefile README.md LICENSE].include? file
path = File.join(ENV['HOME'], ".#{file}")
next if IGNORES.include? file
path = install_path_for file
if File.exist?(path) || File.symlink?(path)
puts "removing existing ~/.#{file}"
system %Q{rm -rf "$HOME/.#{file}"}
puts "Removing #{path}"
FileUtils.rm_rf path
end
puts "linking ~/.#{file}"
system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"}
puts "Linking #{path}"
FileUtils.ln_s File.join(Dir.pwd, file), path
end
end

def install_path_for file
basename = (NO_DOTS.include? file) && file || ".#{file}"
File.join(ENV['HOME'], basename)
end

0 comments on commit 606362b

Please sign in to comment.