Added working_directory parameter

This commit is contained in:
2021-11-30 17:18:31 +01:00
parent b1dc9cd3b3
commit 8efb5a885e
3 changed files with 15 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ A GitHub action for styling files with [prettier](https://prettier.io).
| - | :-: | :-: | - |
| 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 |
| 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 |

View File

@@ -38,6 +38,10 @@ inputs:
description: Specific version of prettier (by default just use the latest version)
required: false
default: false
working_directory:
description: Specify a directory to cd into before installing prettier and running it
required: false
default: false
only_changed:
description: Only prettify files changed in the last commit, can't be used with file_pattern!
required: false
@@ -45,13 +49,12 @@ inputs:
prettier_plugins:
description: Install Prettier plugins, i.e. `@prettier/plugin-php @prettier/plugin-other`
required: false
default: ''
default: ""
github_token:
description: GitHub Token or PAT token used to authenticate against a repository
required: false
default: ${{ github.token }}
runs:
using: "composite"
steps:
@@ -71,6 +74,7 @@ runs:
INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }}
INPUT_ONLY_CHANGED: ${{ inputs.only_changed }}
INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }}
INPUT_WORKING_DIRECTORY: ${{ inputs.working_directory }}
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
branding:

View File

@@ -37,6 +37,14 @@ cd "$GITHUB_ACTION_PATH"
echo "Installing prettier..."
case $INPUT_WORKING_DIRECTORY in
false)
;;
*)
cd $INPUT_WORKING_DIRECTORY
;;
esac
case $INPUT_PRETTIER_VERSION in
false)
npm install --silent prettier