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

feat: add support for capturing and overriding the exit code within run_node #1990

Merged
merged 1 commit into from
Jul 6, 2020

Conversation

mattem
Copy link
Collaborator

@mattem mattem commented Jul 1, 2020

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Feature (please, look at the "Scope of the project" section in the README.md file)

What is the new behavior?

Adds exit_code_out and override_exit_code to npm_package_bin (and handling in run_node) allowing the exit code of the binary to be captured to a file, and the subsequent exit code to then be overridden.

@@ -10,8 +10,10 @@ _ATTRS = {
"args": attr.string_list(mandatory = True),
"configuration_env_vars": attr.string_list(default = []),
"data": attr.label_list(allow_files = True, aspects = [module_mappings_aspect, node_modules_aspect]),
"exit_code_out": attr.output(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exit_code on it's own seemed not descriptive enough, but can change these attr names to something better

# Captures the exit code of the node process to the file specified
--bazel_capture_exit_code=*) EXIT_CODE_CAPTURE="${ARG#--bazel_capture_exit_code=}" ;;
# Overrides the exit code of the node process
--bazel_override_exit_code=*) OVERRIDE_EXIT_CODE="${ARG#--bazel_override_exit_code=}" ;;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a case where you'd want to capture the exit code, and not have it exit zero? If we can't think of one, I think I'd rather keep the feature smaller just so there's less surface area for us to support.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed a natural additional option, but don't have a use case for it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay do you mind simplifying then, and just have the one option to capture, and always exit zero when the option is used?
Also we should document here that you still have to produce all the expected outputs from the program even when expecting a non-zero exit code, as we discovered in your PR that consumes this feature. That restriction does make it a lot less useful... but I'm not sure what else we can do in this model where the program and the error translator are separate actions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do 👍 Will add a note to the npm_package_bin docs too, I couldn't see where the run_node docs are surfaced, but I'll add something in there too I think.

@mattem mattem merged commit cbdd3b0 into bazel-contrib:master Jul 6, 2020
@mattem mattem deleted the feat/exit-code-capture branch March 4, 2021 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants