|
11 | 11 | abstract class AbstractWebEngineCommand extends Command { |
12 | 12 | public function executeScript( |
13 | 13 | ArgumentValueList $arguments = null, |
14 | | - string...$scriptsToRun |
| 14 | + array...$scriptsToRun |
15 | 15 | ):void { |
16 | | - $argString = ""; |
17 | | - |
18 | | - foreach($arguments as $arg) { |
19 | | - $key = $arg->getKey(); |
20 | | - |
21 | | - if($key !== Argument::USER_DATA) { |
22 | | - $argString .= " "; |
23 | | - $argString .= "--"; |
24 | | - $argString .= $key; |
25 | | - } |
26 | | - |
27 | | - $value = $arg->get(); |
28 | | - if(!empty($value)) { |
29 | | - $argString .= " "; |
30 | | - $argString .= $value; |
31 | | - } |
32 | | - } |
33 | | - |
34 | 16 | $processPool = new Pool(); |
35 | 17 |
|
36 | | - foreach($scriptsToRun as $scriptName) { |
| 18 | + foreach($scriptsToRun as $scriptParts) { |
| 19 | + $scriptName = array_shift($scriptParts); |
| 20 | + |
37 | 21 | $gtCommand = implode(DIRECTORY_SEPARATOR, [ |
38 | 22 | "vendor", |
39 | 23 | "bin", |
40 | 24 | $scriptName, |
41 | 25 | ]); |
42 | 26 |
|
43 | | - $spacePos = strpos($gtCommand, " "); |
44 | | - $gtCommandWithoutArguments = $gtCommand; |
45 | | - if($spacePos > 0) { |
46 | | - $gtCommandWithoutArguments = substr( |
47 | | - $gtCommand, |
48 | | - 0, |
49 | | - $spacePos |
50 | | - ); |
51 | | - } |
52 | | - if(!file_exists($gtCommandWithoutArguments)) { |
| 27 | + if(!file_exists($gtCommand)) { |
53 | 28 | $this->writeLine( |
54 | 29 | "The current directory is not a WebEngine application.", |
55 | 30 | Stream::ERROR |
56 | 31 | ); |
57 | 32 | return; |
58 | 33 | } |
59 | 34 |
|
60 | | - if(!empty($argString)) { |
61 | | - $gtCommand .= $argString; |
62 | | - } |
63 | | - |
64 | | - $friendlyScriptName = $gtCommandWithoutArguments; |
65 | | - $slashPos = strrpos($gtCommandWithoutArguments, "/"); |
| 35 | + $friendlyScriptName = $gtCommand; |
| 36 | + $slashPos = strrpos($friendlyScriptName, "/"); |
66 | 37 | if($slashPos > 0) { |
67 | 38 | $friendlyScriptName = substr( |
68 | | - $gtCommandWithoutArguments, |
| 39 | + $friendlyScriptName, |
69 | 40 | $slashPos + 1 |
70 | 41 | ); |
71 | 42 | } |
72 | 43 |
|
73 | | - $process = new Process($gtCommand); |
| 44 | + $process = new Process($gtCommand, ...$scriptParts); |
74 | 45 | $processPool->add($friendlyScriptName, $process); |
75 | 46 | } |
76 | 47 |
|
|
0 commit comments