lib/jekyll-postcss-v2/hook.rb in jekyll-postcss-v2-1.0.1 vs lib/jekyll-postcss-v2/hook.rb in jekyll-postcss-v2-1.0.2

- old
+ new

@@ -2,24 +2,24 @@ require "pathname" module PostCssV2 class Engine - def initialize(source) - @script = Pathname.new(source + "/node_modules/.bin/postcss") - unless @script.exist? + def initialize(source, options = {}) + @script = File.expand_path(options[:script] || 'node_modules/.bin/postcss', source) + unless File.exist?(@script) Jekyll.logger.error "PostCSS v2:", "PostCSS not found. Make sure postcss and postcss-cli are installed in your Jekyll source." Jekyll.logger.error "PostCSS v2:", "Couldn't find #{@script}" exit 1 end - @config = Pathname.new(source + "/postcss.config.js") - unless @config.exist? + @config = File.expand_path(options[:config] || 'postcss.config.js', source) + unless File.exist?(@config) Jekyll.logger.error "PostCSS v2:", "postcss.config.js not found. Make sure it exists in your Jekyll source." Jekyll.logger.error "PostCSS v2:", "Couldn't find #{@config}" @@ -36,9 +36,12 @@ end end Jekyll::Hooks.register :pages, :post_write do |page| if %r!\.css$! =~ page.url - engine = PostCssV2::Engine.new(page.site.source) + engine = PostCssV2::Engine.new(page.site.source, { + script: page.site.config.dig('postcss', 'script'), + config: page.site.config.dig('postcss', 'config'), + }) engine.process(page) end end