diff --git a/.github/workflows/verify_formatting.yaml b/.github/workflows/verify_formatting.yaml index d907e42..82a3c8e 100644 --- a/.github/workflows/verify_formatting.yaml +++ b/.github/workflows/verify_formatting.yaml @@ -21,14 +21,14 @@ jobs: with: node-version: 20 - - name: Get Prettier version from package-lock.json - run: | - PRETTIER_VERSION=$(grep -m 1 'prettier' package-lock.json | cut -d '"' -f 4 | cut -c 2-) - echo $PRETTIER_VERSION + # This installs all dependencies, but if we use "npm install -g prettier", + # then prettier won't pick up the project's .prettierrc file. + - name: Install dependencies + run: npm ci - name: Check formatting run: | - npx --yes prettier@$PRETTIER_VERSION --check --config .prettierrc . + npm run prettier:check - name: Fail if formatting check failed if: failure() diff --git a/package.json b/package.json index afe63cb..baccdb6 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "build": "next build", "start": "next start", "lint": "next lint", + "prettier:check": "npx prettier --check .", "postbuild": "pagefind --site .next/standalone/.next/server/app/articles --output-path public/_pagefind", "stripe:listen": "stripe listen --forward-to 127.0.0.1:3000/api/stripe-webhook", "db:regen": "npx prisma generate",