Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ensure .erb is at end of file name in installation script
  • Loading branch information
ryanb committed Jun 2, 2012
1 parent f57a719 commit c7c437b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Rakefile
Expand Up @@ -11,13 +11,13 @@ task :install do
files << "oh-my-zsh/custom/rbates.zsh-theme"
files.each do |file|
system %Q{mkdir -p "$HOME/.#{File.dirname(file)}"} if file =~ /\//
if File.exist?(File.join(ENV['HOME'], ".#{file.sub('.erb', '')}"))
if File.identical? file, File.join(ENV['HOME'], ".#{file.sub('.erb', '')}")
puts "identical ~/.#{file.sub('.erb', '')}"
if File.exist?(File.join(ENV['HOME'], ".#{file.sub(/\.erb$/, '')}"))
if File.identical? file, File.join(ENV['HOME'], ".#{file.sub(/\.erb$/, '')}")
puts "identical ~/.#{file.sub(/\.erb$/, '')}"
elsif replace_all
replace_file(file)
else
print "overwrite ~/.#{file.sub('.erb', '')}? [ynaq] "
print "overwrite ~/.#{file.sub(/\.erb$/, '')}? [ynaq] "
case $stdin.gets.chomp
when 'a'
replace_all = true
Expand All @@ -27,7 +27,7 @@ task :install do
when 'q'
exit
else
puts "skipping ~/.#{file.sub('.erb', '')}"
puts "skipping ~/.#{file.sub(/\.erb$/, '')}"
end
end
else
Expand All @@ -37,14 +37,14 @@ task :install do
end

def replace_file(file)
system %Q{rm -rf "$HOME/.#{file.sub('.erb', '')}"}
system %Q{rm -rf "$HOME/.#{file.sub(/\.erb$/, '')}"}
link_file(file)
end

def link_file(file)
if file =~ /.erb$/
puts "generating ~/.#{file.sub('.erb', '')}"
File.open(File.join(ENV['HOME'], ".#{file.sub('.erb', '')}"), 'w') do |new_file|
puts "generating ~/.#{file.sub(/\.erb$/, '')}"
File.open(File.join(ENV['HOME'], ".#{file.sub(/\.erb$/, '')}"), 'w') do |new_file|
new_file.write ERB.new(File.read(file)).result(binding)
end
elsif file =~ /zshrc$/ # copy zshrc instead of link
Expand Down

0 comments on commit c7c437b

Please sign in to comment.