mirror of
https://github.com/creyD/prettier_action.git
synced 2026-04-12 19:30:30 +02:00
Added option clean_node_folder for #108
This commit is contained in:
@@ -26,6 +26,7 @@ A GitHub action for styling files with [prettier](https://prettier.io).
|
|||||||
| commit_description | :x: | - | Custom git extended commit message, will be ignored if used with `same_commit` |
|
| commit_description | :x: | - | Custom git extended commit message, will be ignored if used with `same_commit` |
|
||||||
| file_pattern | :x: | `*` | Custom git add file pattern, can't be used with only_changed! |
|
| file_pattern | :x: | `*` | Custom git add file pattern, can't be used with only_changed! |
|
||||||
| prettier_plugins | :x: | - | Install Prettier plugins, i.e. `"@prettier/plugin-php" "@prettier/plugin-other"`. Must be wrapped in quotes since @ is a reserved character in YAML. |
|
| prettier_plugins | :x: | - | Install Prettier plugins, i.e. `"@prettier/plugin-php" "@prettier/plugin-other"`. Must be wrapped in quotes since @ is a reserved character in YAML. |
|
||||||
|
| clean_node_folder | :x: | `true` | Delete the node_modules folder before committing |
|
||||||
| only_changed | :x: | `false` | Only prettify changed files, can't be used with file_pattern! This command works only with the checkout action set to fetch depth '0' (see example 2)|
|
| only_changed | :x: | `false` | Only prettify changed files, can't be used with file_pattern! This command works only with the checkout action set to fetch depth '0' (see example 2)|
|
||||||
| github_token | :x: | `${{ github.token }}` | The default [GITHUB_TOKEN](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret) or a [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token)
|
| github_token | :x: | `${{ github.token }}` | The default [GITHUB_TOKEN](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret) or a [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token)
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ inputs:
|
|||||||
description: GitHub Token or PAT token used to authenticate against a repository
|
description: GitHub Token or PAT token used to authenticate against a repository
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
clean_node_folder:
|
||||||
|
description: Remove the node_modules folder before committing changes
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
@@ -76,6 +80,7 @@ runs:
|
|||||||
INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }}
|
INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }}
|
||||||
INPUT_WORKING_DIRECTORY: ${{ inputs.working_directory }}
|
INPUT_WORKING_DIRECTORY: ${{ inputs.working_directory }}
|
||||||
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
|
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
|
||||||
|
INPUT_CLEAN_NODE_FOLDER: ${{ inputs.clean_node_folder }}
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: "award"
|
icon: "award"
|
||||||
|
|||||||
@@ -74,11 +74,14 @@ echo "Files:"
|
|||||||
prettier $INPUT_PRETTIER_OPTIONS \
|
prettier $INPUT_PRETTIER_OPTIONS \
|
||||||
|| { PRETTIER_RESULT=$?; echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS"; exit 1; }
|
|| { PRETTIER_RESULT=$?; echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS"; exit 1; }
|
||||||
|
|
||||||
# Ignore node modules and other action created files
|
# Removing the node_modules folder, so it doesn't get committed if it is not added in gitignore
|
||||||
if [ -d 'node_modules' ]; then
|
if $INPUT_CLEAN_NODE_FOLDER; then
|
||||||
rm -r node_modules/
|
echo "Deleting node_modules/ folder..."
|
||||||
else
|
if [ -d 'node_modules' ]; then
|
||||||
echo "No node_modules/ folder."
|
rm -r node_modules/
|
||||||
|
else
|
||||||
|
echo "No node_modules/ folder."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f 'package-lock.json' ]; then
|
if [ -f 'package-lock.json' ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user