Class: Flydata::Util::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/flydata/util/shell.rb

Class Method Summary collapse

Class Method Details

.run_bundle_cmd(cmd, option = {}) ⇒ Object

Call this method if cmd includes bundle exec on different path


7
8
9
# File 'lib/flydata/util/shell.rb', line 7

def self.run_bundle_cmd(cmd, option = {})
  run_cmd(cmd, option.merge(bundle: true))
end

.run_cmd(cmd, option = {}) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'lib/flydata/util/shell.rb', line 11

def self.run_cmd(cmd, option = {})
  # To avoid to use same env value in the child process
  env = if option[:bundle]
          { 'BUNDLE_GEMFILE' => nil, 'GEM_HOME' => nil, }
        else
          {}
        end
  Open3.capture3(env, cmd)
end