Skip to content

Commit

Permalink
fix: command delimiter to support pipelining (#114)
Browse files Browse the repository at this point in the history
* fix: command delimiter to support pipelining

Signed-off-by: Chapman Pendery <[email protected]>

* test: pipeline parsing

Signed-off-by: Chapman Pendery <[email protected]>

---------

Signed-off-by: Chapman Pendery <[email protected]>
  • Loading branch information
cpendery authored Dec 12, 2023
1 parent e8053ba commit 6f52657
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/runtime/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type CommandToken = {
isPersistent?: boolean;
};

const cmdDelim = /(\|\|)|(&&)|(;)/;
const cmdDelim = /(\|\|)|(&&)|(;)|(\|)/;
const spaceRegex = /\s/;

export const parseCommand = (command: string): CommandToken[] => {
Expand Down
10 changes: 10 additions & 0 deletions src/tests/runtime/__snapshots__/parser.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,13 @@ exports[`parseCommand cmd value 1`] = `
},
]
`;

exports[`parseCommand cmd1 | cmd2 1`] = `
[
{
"complete": true,
"isOption": false,
"token": "cmd2",
},
]
`;
1 change: 1 addition & 0 deletions src/tests/runtime/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const testData = [
{ command: `cmd ` },
{ command: `cmd "value' ` },
{ command: `cmd "value'\\"\\"" ` },
{ command: `cmd1 | cmd2 ` },
];

describe(`parseCommand`, () => {
Expand Down

0 comments on commit 6f52657

Please sign in to comment.