From 6f52657217d3c6a6ce6b091722e4d63e7b2f15bc Mon Sep 17 00:00:00 2001 From: Chapman Pendery <35637443+cpendery@users.noreply.github.com> Date: Tue, 12 Dec 2023 11:45:15 -0800 Subject: [PATCH] fix: command delimiter to support pipelining (#114) * fix: command delimiter to support pipelining Signed-off-by: Chapman Pendery * test: pipeline parsing Signed-off-by: Chapman Pendery --------- Signed-off-by: Chapman Pendery --- src/runtime/parser.ts | 2 +- src/tests/runtime/__snapshots__/parser.test.ts.snap | 10 ++++++++++ src/tests/runtime/parser.test.ts | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) 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`, () => {