Skip to content

Commit

Permalink
check-prettier
Browse files Browse the repository at this point in the history
Signed-off-by: Hannah Bollar <[email protected]>
  • Loading branch information
hanbollar committed Nov 13, 2023
1 parent ffb1c8b commit 9bd4355
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
22 changes: 6 additions & 16 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,12 @@ jobs:
run: |
npm install
- name: 👷 Format
run: npm run format

- name: Error if there are changed files
- name: 👷 Check if format is needed
run: |
# Get the list of changed files
changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
# Print the changed files
echo "Changed files:"
echo "$changed_files"
# Check if there are any changed files
if [ -n "$changed_files" ]; then
echo "There are changed files. Perform your actions here."
else
echo "No changed files. Skip further actions."
npm run check-prettier
if [ $? -ne 0 ]; then
echo "Some files need formatting. Run 'npm run prettier' to format them."
exit 1
fi
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"test": "jest",
"build": "npx webpack --config webpack.config.js",
"format": "prettier --write \"src/**/*.js\""
"format": "prettier --write \"src/**/*.js\"",
"check-format": "prettier --list-different \"src/**/*.js\""
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 9bd4355

Please sign in to comment.