From e69011521da0a9d4559436da21ea030465e54d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 24 Sep 2011 03:05:36 +0200 Subject: Avoid using pathnames and automatically create the manifest directory if one does not exist yet. --- actionpack/lib/sprockets/assets.rake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/sprockets/assets.rake') diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index 782ea38991..12b954371a 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -8,10 +8,15 @@ namespace :assets do ENV["RAILS_ENV"] ||= "production" Kernel.exec $0, *ARGV else + require "fileutils" Rake::Task["tmp:cache:clear"].invoke Rails.application.initialize!(:assets) Sprockets::Bootstrap.new(Rails.application).run + unless Rails.application.config.assets.enabled + raise "Cannot precompile assets if sprockets is disabled. Please set config.assets.enabled to true" + end + # Ensure that action view is loaded and the appropriate sprockets hooks get executed ActionView::Base @@ -20,11 +25,13 @@ namespace :assets do config = Rails.application.config env = Rails.application.assets - target = Pathname.new(File.join(Rails.public_path, config.assets.prefix)) - manifest_path = config.assets.manifest || target + target = File.join(Rails.public_path, config.assets.prefix) static_compiler = Sprockets::StaticCompiler.new(env, target, :digest => config.assets.digest) + manifest = static_compiler.precompile(config.assets.precompile) + manifest_path = config.assets.manifest || target + FileUtils.mkdir_p(manifest_path) File.open("#{manifest_path}/manifest.yml", 'wb') do |f| YAML.dump(manifest, f) -- cgit v1.2.3