From e0fb4eb439ac3a9e5996d09704eb1599ef3c2dd1 Mon Sep 17 00:00:00 2001 From: Conrad Date: Tue, 24 Mar 2020 00:15:08 +0100 Subject: [PATCH 1/6] Added prettier_version parameter --- README.md | 1 + action.yml | 4 ++++ entrypoint.sh | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 536a28c..f705bd7 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ 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. | +| prettier_version | :x: | False | Specific prettier version (by default use latest) | | prettier_options | :x: | `--write **/*.js` | Prettier options (by default it applies to the whole repository) | | commit_options | :x: | - | Custom git commit options | | commit_message | :x: | Prettified Code! | Custom git commit message | diff --git a/action.yml b/action.yml index 41e867c..33f6041 100644 --- a/action.yml +++ b/action.yml @@ -26,6 +26,10 @@ inputs: description: Running the script in dry mode just shows whether there are files that should be prettified or not required: false default: False + prettier_version: + description: Specific version of prettier (by default just use the latest version) + required: false + default: False runs: using: 'docker' diff --git a/entrypoint.sh b/entrypoint.sh index 662c7d3..150a669 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,7 +37,11 @@ _git_push() { # PROGRAM echo "Installing prettier..." -npm install --silent --global prettier +if $INPUT_PRETTIER_VERSION; then + npm install --silent --global prettier@$INPUT_PRETTIER_VERSION +else + npm install --silent --global prettier +fi echo "Prettifing files..." echo "Files:" From 158b31956c0aec74b632b729fa9c7c82bdf9a5c6 Mon Sep 17 00:00:00 2001 From: Conrad Date: Tue, 24 Mar 2020 00:26:22 +0100 Subject: [PATCH 2/6] Stepped Up Badge Game --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index f705bd7..88fec9e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ [![CodeFactor](https://www.codefactor.io/repository/github/creyd/prettier_action/badge/master)](https://www.codefactor.io/repository/github/creyd/prettier_action/overview/master) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) +[![License MIT](https://img.shields.io/github/license/creyD/prettier_action)](https://github.com/creyD/prettier_action/blob/master/LICENSE) +[![Latest Release](https://img.shields.io/github/v/release/creyD/prettier_action)](https://github.com/creyD/prettier_action/releases) +[![Contributors](https://img.shields.io/github/contributors-anon/creyD/prettier_action)](https://github.com/creyD/prettier_action/graphs/contributors) +[![Issues](https://img.shields.io/github/issues/creyD/prettier_action)](https://github.com/creyD/prettier_action/issues) + A GitHub action for styling files with [prettier](https://prettier.io). From 66441c9ff3f3eb71846a8bff00c1f045a20a6609 Mon Sep 17 00:00:00 2001 From: Conrad Date: Tue, 24 Mar 2020 09:46:35 +0100 Subject: [PATCH 3/6] Fixed bug with new version parameter --- entrypoint.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 150a669..4c4efcd 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,10 +37,11 @@ _git_push() { # PROGRAM echo "Installing prettier..." -if $INPUT_PRETTIER_VERSION; then - npm install --silent --global prettier@$INPUT_PRETTIER_VERSION -else +if ! $INPUT_PRETTIER_VERSION; then npm install --silent --global prettier + +else + npm install --silent --global prettier@$INPUT_PRETTIER_VERSION fi echo "Prettifing files..." From 565d7a7458de689340f1caf8e44fadcdc9ed5a8a Mon Sep 17 00:00:00 2001 From: Conrad Date: Tue, 24 Mar 2020 09:51:18 +0100 Subject: [PATCH 4/6] Attempt 2 on fixing the bug with the new version parameter --- entrypoint.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4c4efcd..00e3485 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,9 +37,8 @@ _git_push() { # PROGRAM echo "Installing prettier..." -if ! $INPUT_PRETTIER_VERSION; then +if ! "$INPUT_PRETTIER_VERSION"; then npm install --silent --global prettier - else npm install --silent --global prettier@$INPUT_PRETTIER_VERSION fi From 65e822b2f3297ffb251f68e0470b0224a54ab85d Mon Sep 17 00:00:00 2001 From: Conrad Date: Tue, 24 Mar 2020 09:56:43 +0100 Subject: [PATCH 5/6] New Parameter Defaults To Null --- action.yml | 1 - entrypoint.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 33f6041..9f26e7f 100644 --- a/action.yml +++ b/action.yml @@ -29,7 +29,6 @@ inputs: prettier_version: description: Specific version of prettier (by default just use the latest version) required: false - default: False runs: using: 'docker' diff --git a/entrypoint.sh b/entrypoint.sh index 00e3485..500329d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,7 +37,7 @@ _git_push() { # PROGRAM echo "Installing prettier..." -if ! "$INPUT_PRETTIER_VERSION"; then +if -z "$INPUT_PRETTIER_VERSION"; then npm install --silent --global prettier else npm install --silent --global prettier@$INPUT_PRETTIER_VERSION From 897359d7a2b0086d6b39228eff677370bd664bea Mon Sep 17 00:00:00 2001 From: Conrad Date: Tue, 24 Mar 2020 10:00:40 +0100 Subject: [PATCH 6/6] Update entrypoint.sh --- entrypoint.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 500329d..b39676d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,10 +37,10 @@ _git_push() { # PROGRAM echo "Installing prettier..." -if -z "$INPUT_PRETTIER_VERSION"; then - npm install --silent --global prettier -else +if "$INPUT_PRETTIER_VERSION"; then npm install --silent --global prettier@$INPUT_PRETTIER_VERSION +else + npm install --silent --global prettier fi echo "Prettifing files..."