Sha256: 4629229543fa95c4b05d9d384d0a63692998efafc648d8c12a0d8d72ee705c40

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true


module Jekyll
  module Esm
    module Managers
      module Bower
        class Error < StandardError; end

        def self.location(config)
          config.dig('esm', 'bower', 'dir') || 'bower_components'
        end

        def self.dist(config)
          config.dig('esm', 'dist') || location(config) || 'bower_components'
        end

        def self.add(package:, site:)
          stdout, stderr, status = Open3.capture3(
            "bower install #{package}",
            chdir: File.expand_path(site.source)
          )

          if site.config.dig('esm', 'strict')
            runtime_error = stdout =~ /ERROR in|SyntaxError/

            raise Error, stderr if stderr.size > 0
            raise Error, stdout if !runtime_error.nil?
          end
        end

        def self.remove(packages:, site:)
          stdout, stderr, status = Open3.capture3(
            "bower uninstall #{packages}",
            chdir: File.expand_path(site.source)
          )

          if site.config.dig('esm', 'strict')
            runtime_error = stdout =~ /ERROR in|SyntaxError/

            raise Error, stderr if stderr.size > 0
            raise Error, stdout if !runtime_error.nil?
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-esm-0.3.1 lib/jekyll-esm/managers/bower.rb
jekyll-esm-0.3.0 lib/jekyll-esm/managers/bower.rb