Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: exit command should work in boolean list if not first item #81

Merged
merged 1 commit into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions mod.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,23 @@ Deno.test("should throw when exit code is non-zero", async () => {
Error,
"Exited with code: 2",
);

await assertRejects(
async () => {
await $`exit 3 && echo 1 && echo 2`;
},
Error,
"Exited with code: 3",
);

// regression test for previous bug
await assertRejects(
async () => {
await $`echo 1 && echo 2 && exit 3`;
},
Error,
"Exited with code: 3",
);
});

Deno.test("should change the cwd, but only in the shell", async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ async function executeBooleanList(list: BooleanList, context: Context): Promise<
);
switch (nextResult.kind) {
case "exit":
return firstResult;
return nextResult;
case "continue":
if (nextResult.changes) {
changes.push(...nextResult.changes);
Expand Down