Another bugfix attempt trying to generate the global flag only if needed

This commit is contained in:
2021-02-19 18:10:42 +01:00
parent b5409d48a9
commit 5c365ab3fa
3 changed files with 10 additions and 9 deletions

View File

@@ -1,4 +0,0 @@
FROM node:lts-alpine3.9
RUN apk update && apk add --no-cache bash git openssh
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -56,6 +56,7 @@ runs:
INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }} INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }}
INPUT_ONLY_CHANGED: ${{ inputs.only_changed }} INPUT_ONLY_CHANGED: ${{ inputs.only_changed }}
INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }} INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }}
PATH: $(cd $GITHUB_ACTION_PATH; npm bin):$PATH
branding: branding:
icon: "award" icon: "award"

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# e is for exiting the script automatically if a command fails, u is for exiting if a variable is not set # e is for exiting the script automatically if a command fails, u is for exiting if a variable is not set
# x would be for showing the commands before they are executed # x would be for showing the commands before they are executed
set -eu set -eux
# FUNCTIONS # FUNCTIONS
# Function for setting up git env in the docker container (copied from https://github.com/stefanzweifel/git-auto-commit-action/blob/master/entrypoint.sh) # Function for setting up git env in the docker container (copied from https://github.com/stefanzweifel/git-auto-commit-action/blob/master/entrypoint.sh)
@@ -25,16 +25,20 @@ _git_changed() {
[[ -n "$(git status -s)" ]] [[ -n "$(git status -s)" ]]
} }
( if [ -n "$GITHUB_ACTION_PATH" ]; then
INPUT_IS_GLOBAL=''
else
INPUT_IS_GLOBAL=--global
fi
# PROGRAM # PROGRAM
echo "Installing prettier..." echo "Installing prettier..."
case $INPUT_PRETTIER_VERSION in case $INPUT_PRETTIER_VERSION in
false) false)
npm install --silent prettier npm install --silent $INPUT_IS_GLOBAL prettier
;; ;;
*) *)
npm install --silent prettier@$INPUT_PRETTIER_VERSION npm install --silent $INPUT_IS_GLOBAL prettier@$INPUT_PRETTIER_VERSION
;; ;;
esac esac
@@ -48,7 +52,7 @@ if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then
exit 1 exit 1
fi fi
done done
npm install --silent $INPUT_PRETTIER_PLUGINS npm install --silent $INPUT_IS_GLOBAL $INPUT_PRETTIER_PLUGINS
fi fi
) )