We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1a9411a commit 9c1cf75Copy full SHA for 9c1cf75
1 file changed
Rakefile
@@ -46,7 +46,12 @@ task :post do
46
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts'])
47
title = ENV["title"] || "new-post"
48
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
49
- date = (Time.parse(ENV['date']) || Time.now).strftime('%Y-%m-%d')
+ begin
50
+ date = (Time.parse(ENV['date']) || Time.now).strftime('%Y-%m-%d')
51
+ rescue Exception => e
52
+ puts "Error - date format must be YYYY-MM-DD, please check you typed it correctly!"
53
+ exit -1
54
+ end
55
filename = File.join(CONFIG['posts'], "#{date}-#{slug}.#{CONFIG['post_ext']}")
56
if File.exist?(filename)
57
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
0 commit comments