-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
42 lines (30 loc) · 971 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
require 'rake'
desc "Hooks the dotfiles into system-standard positions."
task :install do
syms = Dir.glob('*/**{.symlink}')
syms.each do |sym|
file = sym.split('/').last.split('.symlink').last
target = "#{ENV["HOME"]}/.#{file}"
# Backup old version
if File.exists?(target) || File.symlink?(target)
FileUtils.rm_rf(target)
`mv "$HOME/.#{file}" "$HOME/.dotfiles/backup/.#{file}.backup"`
end
`ln -s "$PWD/#{sym}" "#{target}"`
end
end
task :uninstall do
Dir.glob('**/*.symlink').each do |sym|
file = sym.split('/').last.split('.symlink').last
target = "#{ENV["HOME"]}/.#{file}"
# Remove all symlinks created during installation
if File.symlink?(target)
FileUtils.rm(target)
end
# Replace any backups made during installation
if File.exists?("#{ENV["HOME"]}/.#{file}.backup")
`mv "$HOME/.#{file}.backup" "$HOME/.#{file}"`
end
end
end
task :default => 'install'