diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2009-12-31 01:14:23 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2009-12-31 01:14:23 -0500 |
commit | 5d8342cc325bc9f46bfe61bf3534248b6ad3216f (patch) | |
tree | c09553747b2c489524e19d8b9c71868f7256227b /railties/lib | |
parent | 5eb3ceca01d532e5303b4283c691adb953576ff4 (diff) | |
download | rails-5d8342cc325bc9f46bfe61bf3534248b6ad3216f.tar.gz rails-5d8342cc325bc9f46bfe61bf3534248b6ad3216f.tar.bz2 rails-5d8342cc325bc9f46bfe61bf3534248b6ad3216f.zip |
Added .gitkeep to empty directories and --skip-git to skip gitignore/gitkeep files
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/generators/rails/app/app_generator.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 22a27fdac2..c03836ed91 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -34,6 +34,9 @@ module Rails::Generators class_option :skip_prototype, :type => :boolean, :aliases => "-J", :default => false, :desc => "Skip Prototype files" + class_option :skip_git, :type => :boolean, :aliases => "-G", :default => false, + :desc => "Skip Git ignores and keeps" + # Add bin/rails options class_option :version, :type => :boolean, :aliases => "-v", :group => :rails, :desc => "Show Rails version number and quit" @@ -58,7 +61,7 @@ module Rails::Generators def create_root_files copy_file "README" - copy_file "gitignore", ".gitignore" + copy_file "gitignore", ".gitignore" unless options[:skip_git] template "Rakefile" template "config.ru" template "Gemfile" @@ -101,7 +104,7 @@ module Rails::Generators def create_lib_files empty_directory "lib" - empty_directory "lib/tasks" + empty_directory_with_gitkeep "lib/tasks" end def create_log_files @@ -124,7 +127,7 @@ module Rails::Generators end def create_public_stylesheets_files - directory "public/stylesheets" + empty_directory_with_gitkeep "public/stylesheets" end def create_prototype_files @@ -149,13 +152,13 @@ module Rails::Generators inside "tmp" do %w(sessions sockets cache pids).each do |dir| - empty_directory dir + empty_directory_with_gitkeep(dir) end end end def create_vendor_files - empty_directory "vendor/plugins" + empty_directory_with_gitkeep "vendor/plugins" end def apply_rails_template @@ -165,7 +168,6 @@ module Rails::Generators end protected - attr_accessor :rails_template def set_default_accessors! @@ -219,5 +221,10 @@ module Rails::Generators "/opt/lampp/var/mysql/mysql.sock" # xampp for linux ].find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ end + + def empty_directory_with_gitkeep(destination, config = {}) + empty_directory(destination, config) + create_file("#{destination}/.gitkeep") unless options[:skip_git] + end end end |