Fixed command piping
This commit is contained in:
parent
0bd7e8502b
commit
3b5f205b92
1 changed files with 6 additions and 4 deletions
|
|
@ -208,19 +208,21 @@ export function Terminal({ startPath, input, setTitle, close: exit, active }) {
|
|||
setHistoryIndex(0);
|
||||
|
||||
// Piping is used to chain commands
|
||||
const pipes = value.split(" | ");
|
||||
let pipes = value.split(" | ");
|
||||
const completedPipes = [];
|
||||
|
||||
let output = null;
|
||||
pipes.forEach((pipe, index) => {
|
||||
removeFromArray(pipe[index - 1], pipes);
|
||||
|
||||
pipes.forEach((pipe) => {
|
||||
if (output instanceof Stream)
|
||||
return;
|
||||
|
||||
// Output from the previous command gets added as an argument for the next command
|
||||
output = handleInput(output ? `${pipe} ${output}` : pipe);
|
||||
completedPipes.push(pipe);
|
||||
});
|
||||
|
||||
pipes = pipes.filter((pipe) => !completedPipes.includes(pipe));
|
||||
|
||||
if (output) {
|
||||
if (output instanceof Stream) {
|
||||
connectStream(output, pipes);
|
||||
|
|
|
|||
Loading…
Reference in a new issue