From 656daa9f97e5be763961d4928005770fa41a9eda Mon Sep 17 00:00:00 2001 From: "Sebastian K. Sorensen" Date: Sun, 10 Jan 2021 16:07:31 +0100 Subject: [PATCH] Attempt of checking plugin name with regex --- entrypoint.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8cabb43..32e83d1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,15 +30,25 @@ echo "Installing prettier..." case $INPUT_PRETTIER_VERSION in false) npm install --silent --global prettier - if [[ -n $INPUT_PRETTIER_PLUGINS ]]; then - npm install --silent --global $INPUT_PRETTIER_PLUGINS - fi ;; *) npm install --silent --global prettier@$INPUT_PRETTIER_VERSION ;; esac +# Install plugins +if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then + for plugin in $INPUT_PRETTIER_PLUGINS; do + # check regex against @prettier/xyz + REGEX = '(@prettier\/)+(plugin-[a-z\-]+)' + if ! [ "$plugin" =~ "$REGEX" ] + echo "Specified plugins does not seem to be valid @prettier/x plugins." + exit 1 + fi + done + npm install --silent --global $INPUT_PRETTIER_PLUGINS +fi + echo "Prettifing files..." echo "Files:" prettier $INPUT_PRETTIER_OPTIONS || echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS"