From d04162ee72db6a44a94d32dfe75bc89161e78b83 Mon Sep 17 00:00:00 2001 From: Conrad Date: Wed, 24 May 2023 11:01:47 +0200 Subject: [PATCH] Added default for prettier_version --- README.md | 4 ++-- action.yml | 2 +- entrypoint.sh | 15 ++------------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 9699de1..e3fedb5 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ A GitHub action for styling files with [prettier](https://prettier.io). | Parameter | Required | Default | Description | | - | :-: | :-: | - | | dry | :x: | `false` | Runs the action in dry mode. Files wont get changed and the action fails if there are unprettified files. Recommended to use with prettier_options --check | -| prettier_version | :x: | `false` | Specific prettier version (by default use latest) | -| working_directory | :x: | `false` | Specify a directory to cd into before installing prettier and running it, use relative file path to the repository root for example `app/` | +| prettier_version | :x: | `latest` | Specific prettier version (by default use latest) | +| working_directory | :x: | - | Specify a directory to cd into before installing prettier and running it, use relative file path to the repository root for example `app/` | | prettier_options | :x: | `"--write **/*.js"` | Prettier options (by default it applies to the whole repository) | | commit_options | :x: | - | Custom git commit options | | push_options | :x: | - | Custom git push options | diff --git a/action.yml b/action.yml index dbc06e0..78c267f 100644 --- a/action.yml +++ b/action.yml @@ -37,7 +37,7 @@ inputs: prettier_version: description: Specific version of prettier (by default just use the latest version) required: false - default: false + default: "latest" working_directory: description: Specify a directory to cd into before installing prettier and running it required: false diff --git a/entrypoint.sh b/entrypoint.sh index 28affa1..1f95c4d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -26,10 +26,6 @@ _git_changed() { [[ -n "$(git status -s)" ]] } -_git_changes() { - git diff -} - ( # PROGRAM # Changing to the directory @@ -45,14 +41,7 @@ case $INPUT_WORKING_DIRECTORY in ;; esac -case $INPUT_PRETTIER_VERSION in - false) - npm install --silent prettier - ;; - *) - npm install --silent prettier@$INPUT_PRETTIER_VERSION - ;; -esac +npm install --silent prettier@$INPUT_PRETTIER_VERSION # Install plugins if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then @@ -97,7 +86,7 @@ if _git_changed; then # case when --write is used with dry-run so if something is unpretty there will always have _git_changed if $INPUT_DRY; then echo "Unpretty Files Changes:" - _git_changes + git diff echo "Finishing dry-run. Exiting before committing." exit 1 else