diff --git a/src/runtime/parser.ts b/src/runtime/parser.ts index 4416d3c..3f9226c 100644 --- a/src/runtime/parser.ts +++ b/src/runtime/parser.ts @@ -8,7 +8,7 @@ export type CommandToken = { isPersistent?: boolean; }; -const cmdDelim = /(\|\|)|(&&)|(;)/; +const cmdDelim = /(\|\|)|(&&)|(;)|(\|)/; const spaceRegex = /\s/; export const parseCommand = (command: string): CommandToken[] => { diff --git a/src/tests/runtime/__snapshots__/parser.test.ts.snap b/src/tests/runtime/__snapshots__/parser.test.ts.snap index 9463594..444287e 100644 --- a/src/tests/runtime/__snapshots__/parser.test.ts.snap +++ b/src/tests/runtime/__snapshots__/parser.test.ts.snap @@ -319,3 +319,13 @@ exports[`parseCommand cmd value 1`] = ` }, ] `; + +exports[`parseCommand cmd1 | cmd2 1`] = ` +[ + { + "complete": true, + "isOption": false, + "token": "cmd2", + }, +] +`; diff --git a/src/tests/runtime/parser.test.ts b/src/tests/runtime/parser.test.ts index 8d200bb..37d7dae 100644 --- a/src/tests/runtime/parser.test.ts +++ b/src/tests/runtime/parser.test.ts @@ -23,6 +23,7 @@ const testData = [ { command: `cmd ` }, { command: `cmd "value' ` }, { command: `cmd "value'\\"\\"" ` }, + { command: `cmd1 | cmd2 ` }, ]; describe(`parseCommand`, () => {