Sha256: aed319b8d8634874eca3e8728e98f26e520acb27e6a623fcb8362c49951fb791

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

require "cocaine"

module EmberCli
  class Command
    def initialize(paths:, options: {})
      @paths = paths
      @options = options
    end

    def test
      line = Cocaine::CommandLine.new(paths.ember, "test --environment test")

      line.command
    end

    def build(watch: false)
      "#{ember_build(watch: watch)} | #{tee}"
    end

    private

    attr_reader :options, :paths

    def process_watcher
      options.fetch(:watcher) { EmberCli.configuration.watcher }
    end

    def tee
      Cocaine::CommandLine.
        new(paths.tee, "-a :log").
        command(log: paths.log)
    end

    def ember_build(watch: false)
      line = Cocaine::CommandLine.new(paths.ember, [
        "build",
        ("--watch" if watch),
        ("--watcher :watcher" if process_watcher),
        "--environment :environment",
        "--output-path :output_path",
      ].compact.join(" "))

      line.command(
        environment: build_environment,
        output_path: paths.dist,
        watcher: process_watcher,
      )
    end

    def build_environment
      if EmberCli.env == "production"
        "production"
      else
        "development"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ember-cli-rails-0.7.2 lib/ember_cli/command.rb
ember-cli-rails-0.7.1 lib/ember_cli/command.rb
ember-cli-rails-0.7.0 lib/ember_cli/command.rb
ember-cli-rails-0.6.1 lib/ember_cli/command.rb
ember-cli-rails-0.6.0 lib/ember_cli/command.rb