diff --git a/middleman-core/features/cli_init.feature b/middleman-core/features/cli_init.feature index e359c6ba..795cb925 100644 --- a/middleman-core/features/cli_init.feature +++ b/middleman-core/features/cli_init.feature @@ -6,6 +6,7 @@ Feature: Middleman CLI When I cd to "MY_PROJECT" Then the following files should exist: | Gemfile | + | .gitignore | | config.rb | | source/index.html.erb | | source/images/background.png | diff --git a/middleman-core/lib/middleman-core/templates.rb b/middleman-core/lib/middleman-core/templates.rb index 67808cab..987fbc6d 100644 --- a/middleman-core/lib/middleman-core/templates.rb +++ b/middleman-core/lib/middleman-core/templates.rb @@ -63,6 +63,16 @@ module Middleman::Templates run('bundle install', :capture => true) end end + + # Output a .gitignore file + class_option :git, :type => :boolean, :default => true + + # Write a .gitignore file for project + # @return [void] + def generate_gitignore! + return unless options[:git] + copy_file "shared/gitignore", File.join(location, ".gitignore") + end end end diff --git a/middleman-core/lib/middleman-core/templates/shared/gitignore b/middleman-core/lib/middleman-core/templates/shared/gitignore new file mode 100644 index 00000000..360890e9 --- /dev/null +++ b/middleman-core/lib/middleman-core/templates/shared/gitignore @@ -0,0 +1,14 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile ~/.gitignore_global + +# Ignore bundler config +/.bundle + +# Ignore the build directory +/build + +# Ignore Sass' cache +/.sass-cache