Sha256: 71f16d64668a7e4480e54dcd2fdbf1c64bd47e8e1328f58f0e9a2c74e9f47421

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

# frozen_string_literal: true

require "open3"

module Jekyll
  module Converters
    class PostCss < Converter
      safe true
      priority :low

      def matches(ext)
        ext.casecmp(".css").zero?
      end

      def output_ext(_ext)
        ".css"
      end

      def convert(content)
        raise PostCssNotFoundError unless File.file?("./node_modules/.bin/postcss")

        compiled_css, status = Open3.capture2("./node_modules/.bin/postcss", :stdin_data => content)

        raise PostCssRuntimeError unless status.success?

        compiled_css
      end
    end
  end
end

class PostCssNotFoundError < RuntimeError; end
class PostCssRuntimeError < RuntimeError; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-postcss-0.1.0 lib/jekyll/converters/postcss.rb