Improve the rake install script

This commit is contained in:
Michael Campagnaro 2013-09-24 03:28:40 +00:00
parent 43d767dde0
commit 0735da9821

View File

@ -3,9 +3,12 @@ require 'rake'
desc "install the dot files into user's home directory"
task :install do
replace_all = false
# link dotfiles first
create_dotfile_link
Dir['*'].each do |file|
next if %w[Rakefile README notes fonts iterm id_dsa.pub .git .gitignore].include? file
next if %w[Rakefile README notes fonts iterm id_dsa.pub .git .gitignore gitignore].include? file
if File.exist?(File.join(ENV['HOME'], ".#{file}"))
if replace_all
replace_file(file)
@ -28,7 +31,12 @@ task :install do
end
end
system %Q{mkdir ~/.tmp}
system %Q{mkdir -p ~/.tmp}
end
def create_dotfile_link
system %Q{rm "$HOME/.dotfiles"}
system %Q{ln -s $PWD "$HOME/.dotfiles"}
end
def replace_file(file)
@ -38,5 +46,5 @@ end
def link_file(file)
puts "linking ~/.#{file}"
system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"}
system %Q{ln -s "$HOME/.dotfiles/#{file}" "$HOME/.#{file}"}
end