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,8 +3,11 @@ require 'rake'
desc "install the dot files into user's home directory" desc "install the dot files into user's home directory"
task :install do task :install do
replace_all = false replace_all = false
# link dotfiles first
create_dotfile_link
Dir['*'].each do |file| 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 File.exist?(File.join(ENV['HOME'], ".#{file}"))
if replace_all if replace_all
@ -28,7 +31,12 @@ task :install do
end end
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 end
def replace_file(file) def replace_file(file)
@ -38,5 +46,5 @@ end
def link_file(file) def link_file(file)
puts "linking ~/.#{file}" puts "linking ~/.#{file}"
system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"} system %Q{ln -s "$HOME/.dotfiles/#{file}" "$HOME/.#{file}"}
end end