zx icon indicating copy to clipboard operation
zx copied to clipboard

add postfix option

Open prototypicalpro opened this issue 3 years ago • 4 comments

I'm using zx with powershell, and I noticed that when a command sets an exit code instead of throwing an exception (ex. Azure CLI does this) the exit code doesn't get passed through by default. To resolve this issue I added a $.postfix option:

$.postfix = '; exit $LastExitCode'
await $`az ...` // now throws an exception on failure

I've also added a CLI option and updated the default powershell behavior to include this postfix. These changes work for me but if there is a better way I'd be happy to rework them.

  • [x] Tests pass
  • [x] Appropriate changes to README are included in PR
  • [x] Types updated

prototypicalpro avatar Oct 21 '22 19:10 prototypicalpro

@antongolub

antonmedv avatar Oct 21 '22 19:10 antonmedv

This PR would be very helpful for us running cross-platform tests using zx in CI.

TomAFrench avatar Mar 16 '23 01:03 TomAFrench

@antonmedv does this PR need anything else?

prototypicalpro avatar May 16 '23 22:05 prototypicalpro

bump

prototypicalpro avatar Jun 28 '23 20:06 prototypicalpro

Hey @antonmedv any reason why this was never merged? I still use this change daily, it's great for powershell.

prototypicalpro avatar Mar 28 '24 21:03 prototypicalpro

Lets rebase!

antonmedv avatar Mar 28 '24 21:03 antonmedv