Sha256: ecc6cf7c207bb60fc24bdd897e04260a5b7c6f302dbcd815067feea2a125692f

Contents?: true

Size: 851 Bytes

Versions: 2

Compression:

Stored size: 851 Bytes

Contents

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

module SprocketsExportersFileExporterPatches
  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

# --
module Sprockets
  module Exporters
    class FileExporter
      prepend SprocketsExportersFileExporterPatches
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-assets-3.0.7 lib/jekyll/assets/writer.rb
jekyll-assets-3.0.6 lib/jekyll/assets/writer.rb