-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
core.setOutput should(?) transform data
to a string
#370
Comments
@thboop thoughts? I think this makes sense. Especially given common cases like bool/number. The only thing that worries me a little bit, is if we ever preserve type/structure in the future. Basically to enable something like I wonder for arrays/objects, whether we should convert to json (indented?) or just defer to however nodejs converts to string - for example: `${[1, 2, 3]}` // '1,2,3' i kind of like just doing whatever nodejs does (no magic) |
Thanks for sharing those thoughts @ericsciple, there are a couple of complications you mentioned.
This is an interesting choice; using the String({ test: true })
// -> "[object Object]" Which is not at all useful. This is way better: JSON.stringify({ test: true })
// -> '{ "test": true }'
|
I think stringifying makes a lot of sense. Bools and numbers are probably the most common case here, but we should consider others (like json).
|
One thing to note is that there may be an expectation that whatever you |
+1 i would just write in the function description that it runs some quirks to be aware of :) JSON.stringify(null) // 'null'
JSON.stringify(undefined) // undefined - so need to explicitly handle undefined |
Fell into this trap: release-drafter/release-drafter#376 (comment) |
Resolved in #405 |
- Log the `message` of the `Error` object. [actions/toolkit#370] - Streamlined output to string for `fromjson`. - Aligned the documenation with the new `object_locations`value. - Regenerated `dist`. Closes shallwefootball#9 Signed-off-by: Akos Kitta <[email protected]>
Describe the enhancement
Hello! In an action I maintain, I call
setOutput
with an issue number. That fails, becausesetOutput
expects it to be a string. This bit me (JasonEtco/create-an-issue#46), and I'm wondering if y'all would be up for transforming the value passed to a string, or throwing if it isn't a string.I realize that this gets into "just use TypeScript" territory, but I see no reason that I shouldn't be able to pass a number aside from the implementation detail of how it works under the hood.
Code Snippet
Additional information
I'm using JasonEtco/actions-toolkit as an opinionated alternative/wrapper for
actions/toolkit
. If transforming the value isn't something y'all feel good about, I'm happy to move that into that more opinionated territory!The text was updated successfully, but these errors were encountered: