Write output from `sh' task action directly:
* Accept output as argument in Remote#execute; * Modify ShellCommand so that env output is directly handled.
This commit is contained in:
@@ -3,7 +3,8 @@ module Producer
|
||||
module Actions
|
||||
class ShellCommand < Action
|
||||
def apply
|
||||
output.puts remote.execute(arguments.first)
|
||||
remote.execute(arguments.first, output)
|
||||
output.puts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -23,8 +23,7 @@ module Producer
|
||||
@fs ||= Remote::FS.new(session.sftp.connect)
|
||||
end
|
||||
|
||||
def execute(command)
|
||||
output = ''
|
||||
def execute(command, output = '')
|
||||
channel = session.open_channel do |channel|
|
||||
channel.exec command do |ch, success|
|
||||
ch.on_data do |c, data|
|
||||
|
@@ -6,18 +6,20 @@ module Producer
|
||||
raise 'no session for mock remote!'
|
||||
end
|
||||
|
||||
def execute(command)
|
||||
def execute(command, output = '')
|
||||
tokens = command.split
|
||||
program = tokens.shift
|
||||
|
||||
case program
|
||||
when 'echo'
|
||||
tokens.join ' '
|
||||
output << tokens.join(' ')
|
||||
when 'true'
|
||||
''
|
||||
output << ''
|
||||
when 'false'
|
||||
raise RemoteCommandExecutionError
|
||||
end
|
||||
|
||||
output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user