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

Add a function for getting only the return code #307

Open
acrodrig opened this issue Feb 14, 2025 · 1 comment
Open

Add a function for getting only the return code #307

acrodrig opened this issue Feb 14, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@acrodrig
Copy link

Just as there are specialized function to retrieve text or json, there should be a function to retrieve the code of the command (in may cases such as in git diff --quiet that is all I am interested in,

Example:

const result = await $`echo 1`.code();
console.log(result); // 0

If I just want the code, then the noThrow should be implicit.

As of now I have to execute the command with noThrow and then fish for the code.

It's a nice to have but I think it would increase the DX.

Thanks for a great library.

@acrodrig
Copy link
Author

Another good example of where to use it is deno fmt --check

@dsherret dsherret added the enhancement New feature or request label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants