forked from joshuaclayton/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
70 lines (61 loc) · 1.42 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class Installer
def symlink(target, link)
if File.symlink?(link)
unlink(link)
elsif File.exist?(link)
puts "ERROR: File exists: #{link}"
exit 1
end
puts "Symlinking #{link} => #{target}"
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
end
def pwd; File.dirname(__FILE__); end
def target_path(file)
File.join(ENV["HOME"], ".#{file}")
end
files = File.new(File.join(pwd, "MANIFEST"), "r").read.split("\n")
desc "Install all dotfiles"
task :install => [:init_submodules, :update_submodules] do
files.each do |file|
Installer.new.symlink(File.join(pwd, file), target_path(file))
end
end
desc "Remove all dotfies"
task :uninstall do
files.each do |file|
Installer.new.unlink(target_path(file))
end
end
desc "Install submodules"
task :init_submodules do
puts "Installing submodules"
`git submodule init`
end
desc "Update submodules"
task :update_submodules do
puts "Updating submodules"
`git submodule update`
end
desc "Pull in new vim submodules"
task :pull_vim_submodules do
puts "Pull vim submodules"
system(%{
for x in vim/bundle/*; do
echo $x
cd $x
git co master && git pull
cd ../../..
done
})
end