Sha256: 94fc216a55c7aed1e29e5beb8bdf21783e5ff19ca16ba528048a30250579ea61

Contents?: true

Size: 886 Bytes

Versions: 5

Compression:

Stored size: 886 Bytes

Contents

# Frozen-string-literal: true
# Copyright: 2012 - 2018 - MIT License
# Encoding: utf-8

if defined?(Sprockets::Exporters)
  module SprocketsWriterPatches
    def skip?(logger)
      return true if File.exist?(target)
      logger.debug "Writing asset to #{target}"
      false
    end

    # --
    def call
      before_hook(asset, env: environment)
      after_hook(out = super, {
        env: environment, asset: asset
      })

      out
    end

    # --
    private
    def before_hook(asset, env:)
      Jekyll::Assets::Hook.trigger :asset, :before_write do |v|
        v.call(asset, env)
      end
    end

    # --
    private
    def after_hook(out, asset:, env:)
      Jekyll::Assets::Hook.trigger :asset, :after_write do |v|
        v.call(out, asset, env)
      end
    end
  end

  # --
  Sprockets::Exporters::FileExporter.send \
    :prepend, SprocketsWriterPatches
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jekyll-assets-3.0.12 lib/jekyll/assets/writer.rb
jekyll-assets-3.0.11 lib/jekyll/assets/writer.rb
jekyll-assets-3.0.10 lib/jekyll/assets/writer.rb
jekyll-assets-3.0.9 lib/jekyll/assets/writer.rb
jekyll-assets-3.0.8 lib/jekyll/assets/writer.rb