File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,12 @@ task :post do
4646 abort ( "rake aborted: '#{ CONFIG [ 'posts' ] } ' directory not found." ) unless FileTest . directory? ( CONFIG [ 'posts' ] )
4747 title = ENV [ "title" ] || "new-post"
4848 slug = title . downcase . strip . gsub ( ' ' , '-' ) . gsub ( /[^\w -]/ , '' )
49- date = ( Time . parse ( ENV [ 'date' ] ) || Time . now ) . strftime ( '%Y-%m-%d' )
49+ 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
5055 filename = File . join ( CONFIG [ 'posts' ] , "#{ date } -#{ slug } .#{ CONFIG [ 'post_ext' ] } " )
5156 if File . exist? ( filename )
5257 abort ( "rake aborted!" ) if ask ( "#{ filename } already exists. Do you want to overwrite?" , [ 'y' , 'n' ] ) == 'n'
You can’t perform that action at this time.
0 commit comments