diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index 8c625eca46f3..e3227341e0e4 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -21,7 +21,7 @@ jobs: - name: Create NPM cache-hash input file run: | mkdir -p tmp - jq '{devDependencies, dependencies, engines, gitHubActionCacheKey}' package.json > tmp/package-ci.json + jq '{devDependencies, engines, gitHubActionCacheKey}' package.json > tmp/package-ci.json - uses: actions/setup-node@v4 with: @@ -29,5 +29,11 @@ jobs: cache: npm cache-dependency-path: tmp/package-ci.json - - name: Check file format - run: npm run check:format --ignore-scripts + - name: Install package(s) + run: | + PRETTIER_AT_VERS=@$(npm pkg get devDependencies.prettier | tr -d '^"') + echo "PRETTIER_AT_VERS=$PRETTIER_AT_VERS" | tee -a $GITHUB_ENV + npm install prettier$PRETTIER_AT_VERS --no-save + set -x && npx prettier --version + + - run: npm run check:format diff --git a/package.json b/package.json index 780fba349406..41d1c2c58c83 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,11 @@ "scripts": { "__check:links": "make --keep-going check-links", "_build": "npm run _hugo -- -e dev --buildDrafts --baseURL \"${DEPLOY_PRIME_URL:-http://localhost}\"", - "_check:format:any": "npx prettier --check --ignore-path ''", + "__check:format": "npx prettier${PRETTIER_AT_VERS}", + "_check:format:any": "npm run __check:format -- --check --ignore-path ''", "_check:format:ja+zh": "npm run _check:format:nowrap -- content/ja content/zh", "_check:format:nowrap": "npm run _check:format:any -- --prose-wrap preserve", - "_check:format": "npx prettier --check .", + "_check:format": "npm run __check:format -- --check .", "_check:links--md": "npx markdown-link-check --config .markdown-link-check.json *.md", "_check:links--warn": "npm run _check:links || (echo; echo 'WARNING: see link-checker output for issues.'; echo)", "_check:links:internal": "npm run __check:links", @@ -120,7 +121,7 @@ "markdown-link-check": "^3.13.6", "markdownlint": "^0.36.1", "postcss-cli": "^11.0.0", - "prettier": "^3.4.2", + "prettier": "3.4.2", "require-dir": "^1.2.0", "textlint": "^14.4.0", "textlint-filter-rule-allowlist": "^4.0.0",