forked from ebeigarts/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
40 lines (37 loc) · 1.15 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'rake'
desc "install the dot files into user's home directory"
task :install do
replace_all = false
Dir['*'].each do |file|
next if %w[Rakefile README.md LICENSE osx].include? file
target_name = %[bin login.sql].include?(file) ? file : ".#{file}"
if File.exist?(File.join(ENV['HOME'], target_name))
if replace_all
replace_file(file, target_name)
else
print "overwrite ~/#{target_name}? [ynaq] "
case $stdin.gets.chomp
when 'a'
replace_all = true
replace_file(file, target_name)
when 'y'
replace_file(file, target_name)
when 'q'
exit
else
puts "skipping ~/#{target_name}"
end
end
else
replace_file(file, target_name)
end
end
system "GEM_HOME=~/.gem/ruby/2.0.0 gem install hirb -v 0.7.0 --no-ri --no-rdoc"
system "GEM_HOME=~/.gem/ruby/2.0.0 gem install awesome_print -v 1.1.0 --no-ri --no-rdoc"
end
task :default => :install
def replace_file(file, target_name)
system %Q{rm -rf "$HOME/#{target_name}"}
puts "linking ~/#{target_name}"
system %Q{ln -s "$PWD/#{file}" "$HOME/#{target_name}"}
end