Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix for the error on post creation if date was not specified.

  • Loading branch information...
commit 9a69c8ed2470d8ff74736a45c8dbc42786ecbceb 1 parent cefdd4e
@alishutc alishutc authored plusjade committed
Showing with 3 additions and 3 deletions.
  1. +3 −3 Rakefile
View
6 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
Please sign in to comment.
Something went wrong with that request. Please try again.