mirror of
https://github.com/creyD/prettier_action.git
synced 2026-04-15 21:00:35 +02:00
Merge pull request #1 from sebastianks/check-plugin-name
Attempt of checking plugin name with regex
This commit is contained in:
@@ -30,15 +30,25 @@ echo "Installing prettier..."
|
|||||||
case $INPUT_PRETTIER_VERSION in
|
case $INPUT_PRETTIER_VERSION in
|
||||||
false)
|
false)
|
||||||
npm install --silent --global prettier
|
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
|
npm install --silent --global prettier@$INPUT_PRETTIER_VERSION
|
||||||
;;
|
;;
|
||||||
esac
|
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 "Prettifing files..."
|
||||||
echo "Files:"
|
echo "Files:"
|
||||||
prettier $INPUT_PRETTIER_OPTIONS || echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS"
|
prettier $INPUT_PRETTIER_OPTIONS || echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS"
|
||||||
|
|||||||
Reference in New Issue
Block a user