Skip to content

Commit 23ceab2

Browse files
committed
update some for exec command
1 parent 7527a94 commit 23ceab2

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/Exec.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,20 @@ public static function exec(string $command, string $workDir = '', bool $outAsSt
5151
*
5252
* @return array
5353
*/
54-
public static function system(string $command, string $workDir = ''): array
54+
public static function system(string $command, string $workDir = '', bool $allReturn = false): array
5555
{
5656
if ($workDir) {
5757
chdir($workDir);
5858
}
5959

60-
ob_start();
61-
system($command, $status);
62-
$output = ob_get_clean();
60+
if ($allReturn) {
61+
ob_start();
62+
system($command, $status);
63+
$output = ob_get_clean();
64+
} else {
65+
// only last line message
66+
$output = system($command, $status);
67+
}
6368

6469
return [$status, $output];
6570
}

src/Proc/ProcWrapper.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,18 @@ public function setCommand(string $command): self
408408
return $this;
409409
}
410410

411+
/**
412+
* @param index $index
413+
* @param array $spec
414+
*
415+
* @return ProcWrapper
416+
*/
417+
public function setDescriptor(int $index, array $spec): self
418+
{
419+
$this->descriptors[$index] = $spec;
420+
return $this;
421+
}
422+
411423
/**
412424
* @param array $descriptors
413425
*

0 commit comments

Comments
 (0)