mirror of
https://github.com/creyD/prettier_action.git
synced 2026-04-15 04:40:33 +02:00
Merge pull request #49 from fsz-codeshop/issue-37-dry-run-reporting-unpretty
Fixes Issues from PR #46 (37 [BUG] Dry run reporting unpretty files when all files match styles)
This commit is contained in:
@@ -26,12 +26,17 @@ _git_changed() {
|
|||||||
[[ -n "$(git status -s)" ]]
|
[[ -n "$(git status -s)" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_git_changes() {
|
||||||
|
git diff
|
||||||
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
# PROGRAM
|
# PROGRAM
|
||||||
# Changing to the directory
|
# Changing to the directory
|
||||||
cd "$GITHUB_ACTION_PATH"
|
cd "$GITHUB_ACTION_PATH"
|
||||||
|
|
||||||
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 prettier
|
||||||
@@ -66,13 +71,12 @@ git reset --hard package-lock.json || rm package-lock.json || echo "No package-
|
|||||||
|
|
||||||
# To keep runtime good, just continue if something was changed
|
# To keep runtime good, just continue if something was changed
|
||||||
if _git_changed; then
|
if _git_changed; then
|
||||||
|
# case when --write is used with dry-run so if something is unpretty there will always have _git_changed
|
||||||
if $INPUT_DRY; then
|
if $INPUT_DRY; then
|
||||||
if [ "$PRETTIER_RESULT" -eq 1 ]; then
|
echo "Unpretty Files Changes:"
|
||||||
echo "Prettier found unpretty files!"
|
_git_changes
|
||||||
exit 1
|
echo "Finishing dry-run. Exiting before committing."
|
||||||
else
|
exit 1
|
||||||
echo "No unpretty files! Finishing dry-run."
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
# Calling method to configure the git environemnt
|
# Calling method to configure the git environemnt
|
||||||
_git_setup
|
_git_setup
|
||||||
@@ -101,5 +105,13 @@ if _git_changed; then
|
|||||||
echo "Changes pushed successfully."
|
echo "Changes pushed successfully."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
# case when --check is used so there will never have something to commit but there are unpretty files
|
||||||
|
if [ "$PRETTIER_RESULT" -eq 1 ]; then
|
||||||
|
echo "Prettier found unpretty files!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Finishing dry-run."
|
||||||
|
fi
|
||||||
|
echo "No unpretty files!"
|
||||||
echo "Nothing to commit. Exiting."
|
echo "Nothing to commit. Exiting."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user