-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
39 lines (31 loc) · 884 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
require 'rake'
require 'fileutils'
HOME = ENV['HOME']
IGNORE_FILES = %w[Rakefile README.mdown]
COPY_TO = {
"DefaultKeyBinding.dict" => "#{HOME}/Library/KeyBindings",
"com.apple.Terminal.plist" => "#{HOME}/Library/Preferences",
"default-gems" => "#{HOME}/.rbenv"
}
def make_symlink(file)
system "ln -s \"$PWD/#{file}\" \"$HOME/.#{file}\""
end
def replace(file)
FileUtils.remove_entry File.join(HOME, ".#{file}")
make_symlink file
end
task :default => [:install]
task :install do
Dir['*'].each do |file|
next if (IGNORE_FILES.include? file) || ((file =~ /\.sample$/) != nil) || (COPY_TO.has_key? file)
if File.exist?(File.join(HOME, ".#{file}"))
replace file
else
make_symlink file
end
end
COPY_TO.each do |file, destination|
Dir.mkdir(destination) unless File.exists? destination
FileUtils.cp(file, destination)
end
end