-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
50 lines (40 loc) · 978 Bytes
/
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
48
49
50
def symlink(target, link)
puts "Linking #{link} => #{target}"
if File.symlink?(link)
unlink(link)
elsif File.exist?(link)
puts "File exists: #{link}"
exit 0
end
File.symlink(target, link)
end
def delete_symlink(link)
unlink(link) if File.symlink?(link)
end
def unlink(link)
if File.exist?(link)
descriptor = File.symlink?(link) ? "symlink" : "file"
puts "Deleting #{descriptor} #{link}"
File.unlink(link)
end
end
def pwd; File.dirname(__FILE__); end
def target_path(file)
File.join(ENV["HOME"], ".#{file}")
end
files = File.new(File.join(pwd, "files"), "r").read.split("\n")
task :install => [:init_submodules] do
files.each do |file|
symlink(File.join(pwd, file), target_path(file))
end
end
task :uninstall do
files.each do |file|
unlink(target_path(file))
end
end
task :init_submodules do
puts "Installing submodules"
`git submodule update --init --recursive`
end
task :default => [:uninstall, :install]