Add shctx package that mirrors sh and adds a context.Context param#554
Open
sybrenstuvel wants to merge 1 commit into
Open
Add shctx package that mirrors sh and adds a context.Context param#554sybrenstuvel wants to merge 1 commit into
shctx package that mirrors sh and adds a context.Context param#554sybrenstuvel wants to merge 1 commit into
Conversation
Add a new package `shctx` that mirrors the `sh` API, with the addition that each function (where it makes sense) takes a `context.Context` parameter. This can then be used for cancellations, timeouts, etc. Unit tests that were in `sh` have been moved to `shctx`. The `sh` package now no longer has unit tests, because the only thing it does is call into the `shctx` package, and the real work happens there (and is tested). Ref: magefile#228 Related: magefile#444 also adds context support, but has a different approach.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new package
shctxthat mirrors theshAPI, with the addition that each function (where it makes sense) takes acontext.Contextparameter. This can then be used for cancellations, timeouts, etc.Unit tests that were in
shhave been moved toshctx. Theshpackage now no longer has unit tests, because the only thing it does is call into theshctxpackage, and the real work happens there (and is tested).Ref: #228
Related: #444 also adds context support, but has a different approach.
Example use, where two commands are running in parallel, both closing when either one of them has an error or the user presses Ctrl+C (so Mage closes the context):