Add skip-gemfile, skip-bundle, and skip-git options to middleman init, aligning with rails options.

This commit is contained in:
Ben Hollis 2012-09-14 23:31:44 -07:00
parent 266e24e03e
commit e0b88d91be
2 changed files with 17 additions and 4 deletions

View file

@ -28,10 +28,18 @@ module Middleman::Cli
:type => :boolean, :type => :boolean,
:default => false, :default => false,
:desc => 'Include a config.ru file' :desc => 'Include a config.ru file'
method_option "bundler", method_option "skip-gemfile",
:type => :boolean, :type => :boolean,
:default => false, :default => false,
:desc => 'Create a Gemfile and use Bundler to manage gems' :desc => "Don't create a Gemfile"
method_option "skip-bundle",
:type => :boolean,
:default => false,
:desc => "Don't run bundle install"
method_option "skip-git",
:type => :boolean,
:default => false,
:desc => 'Skip Git ignores and keeps'
# The init task # The init task
# @param [String] name # @param [String] name
def init(name) def init(name)

View file

@ -50,23 +50,28 @@ module Middleman::Templates
template "shared/config.ru", File.join(location, "config.ru") template "shared/config.ru", File.join(location, "config.ru")
end end
class_option :'skip-bundle', :type => :boolean, :default => false
class_option :'skip-gemfile', :type => :boolean, :default => false
# Write a Bundler Gemfile file for project # Write a Bundler Gemfile file for project
# @return [void] # @return [void]
def generate_bundler! def generate_bundler!
return if options[:'skip-gemfile']
template "shared/Gemfile.tt", File.join(location, "Gemfile") template "shared/Gemfile.tt", File.join(location, "Gemfile")
return if options[:'skip-bundle']
inside(location) do inside(location) do
::Middleman::Cli::Bundle.new.invoke(:bundle) ::Middleman::Cli::Bundle.new.invoke(:bundle)
end unless ENV["TEST"] end unless ENV["TEST"]
end end
# Output a .gitignore file # Output a .gitignore file
class_option :git, :type => :boolean, :default => true class_option :'skip-git', :type => :boolean, :default => false
# Write a .gitignore file for project # Write a .gitignore file for project
# @return [void] # @return [void]
def generate_gitignore! def generate_gitignore!
return unless options[:git] return if options[:'skip-git']
copy_file "shared/gitignore", File.join(location, ".gitignore") copy_file "shared/gitignore", File.join(location, ".gitignore")
end end
end end