Skip to content

Commit

Permalink
fix asset changes not being picked up after error
Browse files Browse the repository at this point in the history
  • Loading branch information
joshingly committed Jan 28, 2016
1 parent 6e0f061 commit 326dcbb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/middleman-sprockets/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def manipulate_resource_list(resources)
sprockets_resource = generate_resource(r.path, r.source_file, sprockets_path)
sum << sprockets_resource

if sprockets_resource.respond_to?(:sprockets_asset)
if sprockets_resource.respond_to?(:sprockets_asset) && !sprockets_resource.errored?
sprockets_resource.sprockets_asset.links.each do |a|
asset = environment[a]
path = "#{app.config[:sprockets_imported_asset_path]}/#{asset.logical_path}"
Expand Down Expand Up @@ -125,7 +125,7 @@ def generate_resource(path, source_file, sprockets_path)
e.to_s
end

::Middleman::Sitemap::StringResource.new(app.sitemap, path, error_message)
SprocketsResource.new(app.sitemap, path, source_file, sprockets_path, environment, error_message: error_message)
end
end

Expand Down Expand Up @@ -223,15 +223,20 @@ def append_paths_from_gems
end

class SprocketsResource < ::Middleman::Sitemap::Resource
def initialize(store, path, source_file, sprockets_path, environment)
def initialize(store, path, source_file, sprockets_path, environment, error_message: '')
@path = path
@sprockets_path = sprockets_path
@environment = environment
@source = sprockets_asset.source
@error_message = error_message
@source = errored? ? @error_message : sprockets_asset.source

super(store, path, source_file)
end

def errored?
!@error_message.empty?
end

def template?
true
end
Expand Down

0 comments on commit 326dcbb

Please sign in to comment.