mirror of
https://github.com/creyD/prettier_action.git
synced 2026-04-15 04:40:33 +02:00
Merge pull request #5 from sebastianks/master
Add regex check of plugin names
This commit is contained in:
@@ -30,15 +30,26 @@ 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
|
||||||
|
echo "checking $plugin"
|
||||||
|
# check regex against @prettier/xyz
|
||||||
|
if ! echo "$plugin" | grep -Eq '(@prettier\/)+(plugin-[a-z\-]+)'; then
|
||||||
|
echo "$plugin does not seem to be a valid @prettier/plugin-x plugin."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "$plugin seem to be a valid Prettier plugin"
|
||||||
|
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