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

Small fixes for branch dev #57

Merged
merged 4 commits into from
Sep 7, 2021
Merged

Small fixes for branch dev #57

merged 4 commits into from
Sep 7, 2021

Conversation

hpedrorodrigues
Copy link
Contributor

@hpedrorodrigues hpedrorodrigues commented Jun 22, 2021

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 parameter github_token is set
I'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.

Error:  No parser and no file path given, couldn't infer a parser.
Problem running prettier with --write **/*.{ts,tsx,js,json,md}
rm: cannot remove 'node_modules/': No such file or directory
No node_modules/ folder.
fatal: ambiguous argument 'package-lock.json': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
/home/runner/work/_actions/creyD/prettier_action/dev/entrypoint.sh: line 70:  rm: command not found
No package-lock.json file.

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 the command not found error. I've changed to whitespace.


Problem 3: Variable INPUT_PUSH_OPTIONS is handled as if it is required but it is not
Due to the modifier set -u, it's not allowed to use a variable that is not set, but this parameter is optional. Causing the error INPUT_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.

prettier_options: --write **/*.{ts,tsx,json}

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.

@hpedrorodrigues hpedrorodrigues changed the title Bugfixes in branch dev Small fixes for branch dev Jun 26, 2021
@creyD
Copy link
Owner

creyD commented Jul 15, 2021

Thanks so much, I will check today in the evening!

@creyD creyD merged commit c392c4f into creyD:dev Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants