Skip to content

Commit

Permalink
Add debugging information for check format/format (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
SleeplessByte authored Sep 4, 2021
1 parent 9f0e585 commit 0760457
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/verify-code-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
steps:
- name: 'Checkout code'
uses: actions/checkout@v2

- name: Use Node.js LTS (14.x)
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: 'Verify formatting of all files'
run: ./bin/check-formatting.sh
23 changes: 17 additions & 6 deletions bin/check-formatting.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
#!/bin/bash

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
echo "Pulling prettier version from package.json"
EXERCISM_PRETTIER_VERSION=$(npm list prettier | grep -Po '.*prettier@\K.*')
echo "Pulling prettier version from package.json"
EXERCISM_PRETTIER_VERSION=$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')
fi

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://github.com/exercism/v3/blob/master/docs/maintainers/style-guide.md for guidance."
exit 1
echo "---------------------------------------------------"
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance."
echo "---------------------------------------------------"
echo "This is what yarn list reports:"
echo "$(yarn list prettier)"
echo ""
echo "This is the version that can be extracted:"
echo "$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')"
echo ""
echo "These files are found in the repo root:"
echo "$(ls -p | grep -v /)"
echo "---------------------------------------------------"
exit 1
else
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION"
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION"
fi

npx "prettier@$EXERCISM_PRETTIER_VERSION" --check "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"
23 changes: 17 additions & 6 deletions bin/format.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
#!/usr/bin/env bash

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
echo "Pulling prettier version from package.json"
EXERCISM_PRETTIER_VERSION=$(npm list prettier | grep -Po '.*prettier@\K.*')
echo "Pulling prettier version from package.json"
EXERCISM_PRETTIER_VERSION=$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')
fi

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://github.com/exercism/v3/blob/master/docs/maintainers/style-guide.md for guidance."
exit 1
echo "---------------------------------------------------"
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance."
echo "---------------------------------------------------"
echo "This is what yarn list reports:"
echo "$(yarn list prettier)"
echo ""
echo "This is the version that can be extracted:"
echo "$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')"
echo ""
echo "These files are found in the repo root:"
echo "$(ls -p | grep -v /)"
echo "---------------------------------------------------"
exit 1
else
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION"
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION"
fi

npx "prettier@$EXERCISM_PRETTIER_VERSION" --write "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"

0 comments on commit 0760457

Please sign in to comment.