Skip to content

Commit 38b4de3

Browse files
committed
Fix closure output so that it only applies to that run
I mistakenly hacked in the functionality using the current displayStdout functionality which was incorrect. Needs to only use that function on the output of the current command, and not set it across the board.
1 parent e96a350 commit 38b4de3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/MrRio/ShellWrap.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@ private static function __run($arguments)
5454
{
5555
// Unwind the args, figure out which ones were passed in as an array
5656
self::$stdin = null;
57+
$closureOut = false;
5758

5859
foreach ($arguments as $arg_key => $argument) {
5960
// If it's being passed in as an object, then pipe into stdin
6061
if (is_object($argument)) {
6162

6263
// If it's a anonymous function, then push stdout into it
6364
if (get_class($argument) == 'Closure') {
64-
self::$displayStdout = $argument;
65+
$closureOut = $argument;
6566
unset($arguments[$arg_key]);
6667
} else {
6768
self::$stdin = strval($argument);
@@ -155,6 +156,9 @@ private static function __run($arguments)
155156
$outputFunction($stdout);
156157
}
157158

159+
if (is_callable($closureOut)) {
160+
$closureOut($stdout);
161+
}
158162
$output .= $stdout;
159163
}
160164

0 commit comments

Comments
 (0)