Sha256: ce226eea28d4977721125e343db2e11f2d37984579a4a14d05b9ec2b163bfbbf

Contents?: true

Size: 727 Bytes

Versions: 2

Compression:

Stored size: 727 Bytes

Contents

require "open3"

module Bower
  class Command
    attr_reader :cwd

    def initialize(cwd)
      @cwd = cwd
    end

    def install!
      bower(cwd, "install --production --force-latest")
    end

    def list!
      bower(cwd, "list --offline")
    end

    def list_paths!
      bower(cwd, "list --paths --offline")
    end

    private

    def bower(cwd, *command)
      command = "bower #{command.join(' ')} --json"
      command += " --config.interactive=false"
      sh(cwd, command)
    end

    def sh(cwd, *cmd)
      cmd = cmd.join(" ")

      output, error, status =
        Open3.capture3(cmd, :chdir => cwd)

      raise CommandError.new(error, cwd, cmd) unless status.success?

      output
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rab-0.1.0 lib/rab/bower/command.rb
rab-0.0.1 lib/rab/bower/command.rb