Skip to content

Commit 9620def

Browse files
authored
[CI] Ensure specified version of Prettier is run in workflow (#5780)
1 parent 0b9b3bc commit 9620def

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

.github/workflows/check-format.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,19 @@ jobs:
2121
- name: Create NPM cache-hash input file
2222
run: |
2323
mkdir -p tmp
24-
jq '{devDependencies, dependencies, engines, gitHubActionCacheKey}' package.json > tmp/package-ci.json
24+
jq '{devDependencies, engines, gitHubActionCacheKey}' package.json > tmp/package-ci.json
2525
2626
- uses: actions/setup-node@v4
2727
with:
2828
node-version-file: .nvmrc
2929
cache: npm
3030
cache-dependency-path: tmp/package-ci.json
3131

32-
- name: Check file format
33-
run: npm run check:format --ignore-scripts
32+
- name: Install package(s)
33+
run: |
34+
PRETTIER_AT_VERS=@$(npm pkg get devDependencies.prettier | tr -d '^"')
35+
echo "PRETTIER_AT_VERS=$PRETTIER_AT_VERS" | tee -a $GITHUB_ENV
36+
npm install prettier$PRETTIER_AT_VERS --no-save
37+
set -x && npx prettier --version
38+
39+
- run: npm run check:format

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
"scripts": {
77
"__check:links": "make --keep-going check-links",
88
"_build": "npm run _hugo -- -e dev --buildDrafts --baseURL \"${DEPLOY_PRIME_URL:-http://localhost}\"",
9-
"_check:format:any": "npx prettier --check --ignore-path ''",
9+
"__check:format": "npx prettier${PRETTIER_AT_VERS}",
10+
"_check:format:any": "npm run __check:format -- --check --ignore-path ''",
1011
"_check:format:ja+zh": "npm run _check:format:nowrap -- content/ja content/zh",
1112
"_check:format:nowrap": "npm run _check:format:any -- --prose-wrap preserve",
12-
"_check:format": "npx prettier --check .",
13+
"_check:format": "npm run __check:format -- --check .",
1314
"_check:links--md": "npx markdown-link-check --config .markdown-link-check.json *.md",
1415
"_check:links--warn": "npm run _check:links || (echo; echo 'WARNING: see link-checker output for issues.'; echo)",
1516
"_check:links:internal": "npm run __check:links",
@@ -120,7 +121,7 @@
120121
"markdown-link-check": "^3.13.6",
121122
"markdownlint": "^0.36.1",
122123
"postcss-cli": "^11.0.0",
123-
"prettier": "^3.4.2",
124+
"prettier": "3.4.2",
124125
"require-dir": "^1.2.0",
125126
"textlint": "^14.4.0",
126127
"textlint-filter-rule-allowlist": "^4.0.0",

0 commit comments

Comments
 (0)