Add force-option to init

This commit is contained in:
Dennis Günnewig 2014-09-09 09:15:58 +02:00
parent 55e3c93278
commit d45911f7b8
6 changed files with 25 additions and 20 deletions

View file

@ -40,6 +40,11 @@ module Middleman::Cli
type: :boolean,
default: false,
desc: 'Skip Git ignores and keeps'
method_option 'force',
type: :boolean,
default: false,
desc: 'Overwrite existing files without any question'
# The init task
# @param [String] name
def init(name='.')

View file

@ -19,17 +19,17 @@ class Middleman::Templates::Default < Middleman::Templates::Base
# Actually output the files
# @return [void]
def build_scaffold!
template 'shared/config.tt', File.join(location, 'config.rb')
copy_file 'default/source/index.html.erb', File.join(location, 'source/index.html.erb')
copy_file 'default/source/layouts/layout.erb', File.join(location, 'source/layouts/layout.erb')
empty_directory File.join(location, 'source', options[:css_dir])
copy_file 'default/source/stylesheets/all.css', File.join(location, 'source', options[:css_dir], 'all.css')
copy_file 'default/source/stylesheets/normalize.css', File.join(location, 'source', options[:css_dir], 'normalize.css')
empty_directory File.join(location, 'source', options[:js_dir])
copy_file 'default/source/javascripts/all.js', File.join(location, 'source', options[:js_dir], 'all.js')
empty_directory File.join(location, 'source', options[:images_dir])
copy_file 'default/source/images/background.png', File.join(location, 'source', options[:images_dir], 'background.png')
copy_file 'default/source/images/middleman.png', File.join(location, 'source', options[:images_dir], 'middleman.png')
template 'shared/config.tt', File.join(location, 'config.rb'), force: options[:force]
copy_file 'default/source/index.html.erb', File.join(location, 'source/index.html.erb'), force: options[:force]
copy_file 'default/source/layouts/layout.erb', File.join(location, 'source/layouts/layout.erb'), force: options[:force]
empty_directory File.join(location, 'source', options[:css_dir]), force: options[:force]
copy_file 'default/source/stylesheets/all.css', File.join(location, 'source', options[:css_dir], 'all.css'), force: options[:force]
copy_file 'default/source/stylesheets/normalize.css', File.join(location, 'source', options[:css_dir], 'normalize.css'), force: options[:force]
empty_directory File.join(location, 'source', options[:js_dir]), force: options[:force]
copy_file 'default/source/javascripts/all.js', File.join(location, 'source', options[:js_dir], 'all.js'), force: options[:force]
empty_directory File.join(location, 'source', options[:images_dir]), force: options[:force]
copy_file 'default/source/images/background.png', File.join(location, 'source', options[:images_dir], 'background.png'), force: options[:force]
copy_file 'default/source/images/middleman.png', File.join(location, 'source', options[:images_dir], 'middleman.png'), force: options[:force]
end
end

View file

@ -13,8 +13,8 @@ class Middleman::Templates::Empty < Middleman::Templates::Base
# Actually output the files
# @return [void]
def build_scaffold!
create_file File.join(location, 'config.rb'), "\n"
empty_directory File.join(location, 'source')
create_file File.join(location, 'config.rb'), "\n", force: options[:force]
empty_directory File.join(location, 'source'), force: options[:force]
end
end

View file

@ -19,9 +19,9 @@ class Middleman::Templates::Html5 < Middleman::Templates::Base
# Output the files
# @return [void]
def build_scaffold!
template 'shared/config.tt', File.join(location, 'config.rb')
directory 'html5/source', File.join(location, 'source')
empty_directory File.join(location, 'source')
template 'shared/config.tt', File.join(location, 'config.rb'), force: options[:force]
directory 'html5/source', File.join(location, 'source'), force: options[:force]
empty_directory File.join(location, 'source'), force: options[:force]
end
end

View file

@ -9,7 +9,7 @@ class Middleman::Templates::Local < Middleman::Templates::Base
# Just copy from the template path
# @return [void]
def build_scaffold!
directory options[:template].to_s, location
directory options[:template].to_s, location, force: options[:force]
end
end

View file

@ -14,9 +14,9 @@ class Middleman::Templates::Mobile < Middleman::Templates::Base
# Output the files
# @return [void]
def build_scaffold!
template 'shared/config.tt', File.join(location, 'config.rb')
directory 'mobile/source', File.join(location, 'source')
empty_directory File.join(location, 'source')
template 'shared/config.tt', File.join(location, 'config.rb'), force: options[:force]
directory 'mobile/source', File.join(location, 'source'), force: options[:force]
empty_directory File.join(location, 'source'), force: options[:force]
end
end