summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorAlistair Hutchison <github@alistairh.co.uk>2012-03-07 13:28:24 +0000
committerJade Dominguez <plusjade@gmail.com>2012-03-07 14:41:51 -0800
commit9a69c8ed2470d8ff74736a45c8dbc42786ecbceb (patch)
tree6b6a846840e0d04a19c75ade7f92425806e79d37 /Rakefile
parentcefdd4e2c3ff08a1e949e035d492387b90329c88 (diff)
Fix for the error on post creation if date was not specified.
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile6
1 files changed, 3 insertions, 3 deletions
diff --git a/Rakefile b/Rakefile
index 2806bb8..581b869 100644
--- a/Rakefile
+++ b/Rakefile
@@ -40,19 +40,19 @@ module JB
end #Path
end #JB
-# Usage: rake post title="A Title" date="2012-02-09"
+# Usage: rake post title="A Title" [date="2012-02-09"]
desc "Begin a new post in #{CONFIG['posts']}"
task :post do
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts'])
title = ENV["title"] || "new-post"
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
begin
- date = (Time.parse(ENV['date']) || Time.now).strftime('%Y-%m-%d')
+ date = (ENV['date'] ? Time.parse(ENV['date']) : Time.now).strftime('%Y-%m-%d')
rescue Exception => e
puts "Error - date format must be YYYY-MM-DD, please check you typed it correctly!"
exit -1
end
- filename = File.join(CONFIG['posts'], "#{date}-#{slug}.#{CONFIG['post_ext']}")
+ filename = File.join(CONFIG['posts'], "##{date}-#{slug}.#{CONFIG['post_ext']}")
if File.exist?(filename)
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
end