/
Rakefile
49 lines (39 loc) · 1007 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
require 'rake'
desc 'symlink all dot files into the home directory'
task :default do
@ignored_files = ['Rakefile', 'README.md']
perform("Creating vim backups folder") { create_vim_backups_folder }
perform("Updating dotfiles") { git_pull }
perform("Updating submodules") { git_update_submodules }
link_files
end
def git_pull
`git pull`
end
def git_update_submodules
`git submodule update --init --recursive`
`git submodule foreach git checkout master`
`git submodule foreach git pull`
end
def link_files
Dir['*'].each { |file| link_file(file) unless @ignored_files.include?(file) }
end
def link_file(file)
home = `echo $HOME`.strip
if File.exists?("#{home}/.#{file}")
`rm "#{home}/.#{file}"`
end
perform "linking ~/.#{file}" do
`ln -s "$PWD/#{file}" "#{home}/.#{file}"`
end
end
def create_vim_backups_folder
`mkdir -p ~/.vimbackup`
end
def perform(name, &block)
print name
yield
print ' ' * (50 - name.size)
print "DONE"
puts
end