-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
47 lines (39 loc) · 1.43 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
41
42
43
44
45
46
47
require 'rake'
require 'fileutils'
task :install do
# move bash files in
all_opts = { overwrite: false, backup: false }
Dir.glob("home/*").each do |file|
file_opts = { overwrite: false, backup: false }
filename = file.sub("home/", "")
repo_filepath = "#{FileUtils.pwd}/home/#{filename}"
dest_filepath = "#{ENV['HOME']}/.#{filename}"
if File.exists?(dest_filepath) || File.symlink?(dest_filepath)
unless all_opts.any? { |_, v| v == true }
print "File already exists: #{dest_filepath}, "
if FileUtils.compare_file(repo_filepath, dest_filepath)
puts "but does not differ"
else
puts "and differs"
end
puts "What do you want to do? [o]verwrite, [O]verwrite all remaining, [b]ackup, [B]ackup all remaining, [s]kip, [S]kip all remaining"
case STDIN.gets.chomp
when 'o' then file_opts[:overwrite] = true
when 'b' then file_opts[:backup] = true
when 's' then next
when 'O' then all_opts[:overwrite] = true
when 'B' then all_opts[:backup] = true
when 'S' then break
else
puts "not a valid selection. skipping"
next
end
end
if all_opts[:backup] or file_opts[:backup]
FileUtils.mv(dest_filepath, "#{dest_filepath}.backup", verbose: true)
end
end
FileUtils.cp(repo_filepath, dest_filepath, verbose: true)
end
# TODO: vimrc, tmux.conf, etc
end