diff options
Diffstat (limited to 'railties/lib/rails/tasks/railties.rake')
-rw-r--r-- | railties/lib/rails/tasks/railties.rake | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/railties/lib/rails/tasks/railties.rake b/railties/lib/rails/tasks/railties.rake index e08bd9687d..16703879cf 100644 --- a/railties/lib/rails/tasks/railties.rake +++ b/railties/lib/rails/tasks/railties.rake @@ -1,20 +1,29 @@ namespace :railties do - # desc "Create symlinks to railties public directories in application's public directory." - task :create_symlinks => :environment do - paths = Rails.application.config.static_asset_paths.dup - app_public_path = Rails.application.paths["public"].first + namespace :install do + # desc "Copies missing assets from Railties (e.g. plugins, engines). You can specify Railties to use with FROM=railtie1,railtie2" + task :assets => :rails_env do + require 'rails/generators/base' + Rails.application.initialize! - paths.each do |mount_path, path| - symlink_path = File.join(app_public_path, mount_path) - if File.exist?(symlink_path) - File.symlink?(symlink_path) ? FileUtils.rm(symlink_path) : next - end + to_load = ENV["FROM"].blank? ? :all : ENV["FROM"].split(",").map {|n| n.strip } + app_public_path = Rails.application.paths["public"].first - next unless File.exist?(path) + Rails.application.railties.all do |railtie| + next unless to_load == :all || to_load.include?(railtie.railtie_name) - File.symlink(path, symlink_path) + if railtie.respond_to?(:paths) && (path = railtie.paths["public"].first) && + (assets_dir = railtie.config.compiled_asset_path) && File.exist?(path) - puts "Created symlink #{symlink_path} -> #{path}" + Rails::Generators::Base.source_root(path) + copier = Rails::Generators::Base.new + Dir[File.join(path, "**/*")].each do |file| + relative = file.gsub(/^#{path}\//, '') + if File.file?(file) + copier.copy_file relative, File.join(app_public_path, assets_dir, relative) + end + end + end + end end end end |