Sha256: b568074565bca2e65d81db7dcccbc0271f84f61394246aac3f4886114a4f0bf0

Contents?: true

Size: 934 Bytes

Versions: 13

Compression:

Stored size: 934 Bytes

Contents

require File.expand_path("../command", __FILE__)
# require "pry"

module Decko
  module Commands
    class RakeCommand < Command
      def initialize rake_task, args={}
        @task = rake_task
        opts = {}
        if args.is_a? Array
          Parser.new(rake_task, opts).parse!(args)
        else
          opts = args
        end
        @envs = Array(opts[:envs])
      end

      def run
        commands.each do |cmd|
          puts cmd
          # exit_with_child_status cmd

          result = `#{cmd}`
          process = $?
          puts result
          exit process.exitstatus unless process.success?
        end
      end

      def commands
        task_cmd = "bundle exec rake #{@task}"
        return [task_cmd] if !@envs || @envs.empty?
        @envs.map do |env|
          "env RAILS_ENV=#{env} #{task_cmd}"
        end
      end
    end
  end
end

require File.expand_path("../rake_command/parser", __FILE__)

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decko-0.11.4 lib/decko/commands/rake_command.rb
decko-0.11.3 lib/decko/commands/rake_command.rb
decko-0.11.2 lib/decko/commands/rake_command.rb
decko-0.11.1 lib/decko/commands/rake_command.rb
decko-0.11.0 lib/decko/commands/rake_command.rb
decko-0.10.0 lib/decko/commands/rake_command.rb
decko-0.9.6 lib/decko/commands/rake_command.rb
decko-0.9.5 lib/decko/commands/rake_command.rb
decko-0.9.4 lib/decko/commands/rake_command.rb
decko-0.9.3 lib/decko/commands/rake_command.rb
decko-0.9.2 lib/decko/commands/rake_command.rb
decko-0.9.1 lib/decko/commands/rake_command.rb
decko-0.9.0 lib/decko/commands/rake_command.rb