Class: Jank::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/executor.rb

Direct Known Subclasses

Go

Instance Method Summary collapse

Constructor Details

#initialize(c) ⇒ Executor

Returns a new instance of Executor.



5
6
7
# File 'lib/executor.rb', line 5

def initialize(c)
  @config = c
end

Instance Method Details

#apply_package(args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/executor.rb', line 9

def apply_package(args)
  return args if @config.package == nil

  new_args = Array.new
  package_applied = false

  args.each do |a|
    case a
    when /^\./
      package_applied = true
      new_args << a.gsub(/^\./, @config.package)
    when /\//
      package_applied = true
      new_args << a
    when /\.go$/
      package_applied = true
      new_args << a
    else
      new_args << a
    end
  end

  new_args << @config.package if !package_applied
  new_args
end

#execute(cmd, args) ⇒ Object



35
36
37
38
# File 'lib/executor.rb', line 35

def execute(cmd, args)
  Jank.debug_log("🚀  #{cmd} #{args.inspect}")
  Kernel.exec(@config.env, cmd, *args)
end