Permalink
Browse files

ensure .erb is at end of file name in installation script

  • Loading branch information...
1 parent f57a719 commit c7c437b27c4f015bd72c23bc3bd1ce3fc9aed87c @ryanb committed Jun 2, 2012
Showing with 8 additions and 8 deletions.
  1. +8 −8 Rakefile
View
16 Rakefile
@@ -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
@@ -27,7 +27,7 @@ task :install do
when 'q'
exit
else
- puts "skipping ~/.#{file.sub('.erb', '')}"
+ puts "skipping ~/.#{file.sub(/\.erb$/, '')}"
end
end
else
@@ -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

0 comments on commit c7c437b

Please sign in to comment.