aboutsummaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-09-03 08:06:36 -0500
committerBrandon Mathis <brandon@imathis.com>2011-09-03 08:06:36 -0500
commit3f07677276518bc8c035e4af6afe87b5529c550c (patch)
treeddc166f9151579a73804e057d69a945bade5f9e7 /Rakefile
parent724fd1dbc82e3dd15ba6811e27a9259733fb66b9 (diff)
downloadmy_new_personal_website-3f07677276518bc8c035e4af6afe87b5529c550c.tar.xz
my_new_personal_website-3f07677276518bc8c035e4af6afe87b5529c550c.zip
Added prompt for overwriting posts and pages when a new_post and new_page tasks are run and the file already exists. Fixes #130
Diffstat (limited to '')
-rw-r--r--Rakefile10
1 files changed, 10 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
index 2c8b444d..6f7633d0 100644
--- a/Rakefile
+++ b/Rakefile
@@ -92,6 +92,11 @@ task :new_post, :title do |t, args|
args.with_defaults(:title => 'new-post')
title = args.title
filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"
+ if File.exist?(filename)
+ puts "### #{filename} Already exists. Overwrite? y/n:"
+ response = $stdin.gets.chomp.downcase
+ next unless response == 'y'
+ end
puts "Creating new post: #{filename}"
open(filename, 'w') do |post|
system "mkdir -p #{source_dir}/#{posts_dir}/";
@@ -119,6 +124,11 @@ task :new_page, :filename do |t, args|
filename = "#{name}.#{extension}"
mkdir_p page_dir
file = page_dir + filename
+ if File.exist?(file)
+ puts "### #{file} Already exists. Overwrite? y/n:"
+ response = $stdin.gets.chomp.downcase
+ next unless response == 'y'
+ end
puts "Creating new page: #{file}"
open(file, 'w') do |page|
page.puts "---"