lib/spielbash/model/session.rb in spielbash-0.1.0 vs lib/spielbash/model/session.rb in spielbash-0.1.1

- old
+ new

@@ -37,11 +37,11 @@ execute_tmux_with('list-panes -F #{pane_pid}' + " -t #{name}", true) pid = last_stdout.strip return if pid.empty? loop do - execute_with('pgrep', "-P #{pid}", true) + exec_wait_check_cmd(pid) children = last_stdout break if children.empty? end end @@ -56,9 +56,18 @@ execute_with('pgrep', "-P #{pid}", true) execute_with_exactly('asciinema', false, true, false, "rec", "-y", "-c", "tmux attach -t #{name}", "#{output_path}") end private + + def exec_wait_check_cmd(pid) + if context.wait_check_cmd.nil? + execute_with('pgrep', "-P #{pid}", true) + else + cmd = context.wait_check_cmd.split + execute_with_exactly(cmd.first, true, false, true, *cmd.drop(1)) + end + end def execute_tmux_with(arguments, wait = false) execute_with('tmux', arguments, wait) end