diff --git a/bin/jekyll b/bin/jekyll old mode 100755 new mode 100644 index 2e631bbb..b2c6fab9 --- a/bin/jekyll +++ b/bin/jekyll @@ -37,8 +37,10 @@ command :new do |c| c.syntax = 'jekyll new PATH' c.description = 'Creates a new Jekyll site scaffold in PATH' + c.option '--force', 'Force creation even if PATH already exists' + c.action do |args, options| - Jekyll::Commands::New.process(args) + Jekyll::Commands::New.process(args, options.__hash__) end end diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index f6c38fc7..fc8a96f7 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -3,12 +3,12 @@ require 'erb' module Jekyll module Commands class New < Command - def self.process(args) + def self.process(args, options = {}) raise ArgumentError.new('You must specify a path.') if args.empty? new_blog_path = File.expand_path(args.join(" "), Dir.pwd) FileUtils.mkdir_p new_blog_path - unless Dir["#{new_blog_path}/**/*"].empty? + if !options[:force] && !Dir["#{new_blog_path}/**/*"].empty? Jekyll::Stevenson.error "Conflict:", "#{new_blog_path} exists and is not empty." exit(1) end