Method: Lexicon::Common::ShellExecutor#execute

Defined in:
lib/lexicon/common/shell_executor.rb

#execute(command) ⇒ String

Parameters:

  • command (String)

Returns:

  • (String)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lexicon/common/shell_executor.rb', line 15

def execute(command)
  log(command.cyan)

  cmd = Tempfile.new('command-', @command_dir)
  cmd.write <<~BASH
    #!/usr/bin/env bash
    set -e

    #{command}
  BASH
  cmd.close

  `bash #{cmd.path}`
ensure
  cmd.close
  cmd.unlink
end