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.
Hi, I've tried to use the branch
dev
in a personal project and I've found some issues throughout the process.This PR is an attempt to fix these issues. If you think it's better to split into multiple PRs, please, let me know.
Problem 1: Missing environment variable
INPUT_GITHUB_TOKEN
even when the parametergithub_token
is setI've added this env var following the same pattern used for the other ones.
Problem 2: Several errors are printed when prettier doesn't run successfully
i.e.
Basically, this whole output is printed because we weren't checking if the generated files/directories exist before trying to delete them.
Also, before the command
rm
there was a special character, causing thecommand not found
error. I've changed to whitespace.Problem 3: Variable
INPUT_PUSH_OPTIONS
is handled as if it is required but it is notDue to the modifier
set -u
, it's not allowed to use a variable that is not set, but this parameter is optional. Causing the errorINPUT_PUSH_OPTIONS: unbound variable
when we don't set it.I've used an empty string as the default value when this variable is not set.
Problem 4: The action continues to run normally even when prettier doesn't run successfully, causing the action to complete without errors
I've added an
exit 1
command when prettier doesn't run successfully.Problem 5: A generic error is printed when an invalid glob pattern is passed as parameter
When we pass an invalid pattern to the
prettier_options
parameter a generic error message is printed by prettier:Error: No parser and no file path given, couldn't infer a parser.
This happens due to the shell option
nullglob
that makes bash handle this string as a null one instead of its current value.i.e.
In this case, if the pattern
**/*.{ts,tsx,json}
doesn't match any file, only the flag--write
will be passed to prettier, and the generic message will be printed.I've removed this shell option, tested it with the same parameter, and now this message is printed:
No files matching the pattern were found: "**/**/*.{ts}".
Notes: If you have any concerns or comments, please, let me know.