Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit e9584a9

Browse files
committed
Add prettier2/prettier3 scripts for sanity checks
1 parent c408323 commit e9584a9

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
"playground": "npx http-server playground",
3939
"prepare": "husky install",
4040
"prerelease": "scripts/prerelease",
41-
"prettier": "prettier --plugin . --parser=liquid-html",
41+
"prettier": "scripts/prettier",
42+
"prettier2": "cross-env PRETTIER_MAJOR=2 scripts/prettier",
43+
"prettier3": "cross-env PRETTIER_MAJOR=3 scripts/prettier",
4244
"test": "node_modules/.bin/mocha '{src,test}/**/*.spec.ts'",
4345
"test:3": "cross-env PRETTIER_MAJOR=3 yarn test",
4446
"test:idempotence": "cross-env TEST_IDEMPOTENCE=true node_modules/.bin/mocha 'test/**/*.spec.ts'",

scripts/prettier

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
cleanup() {
4+
rm node_modules/prettier
5+
}
6+
7+
run() {
8+
echo "$@"
9+
$@
10+
}
11+
12+
if [[ $PRETTIER_MAJOR = 3 ]]; then
13+
prettier='./prettier3'
14+
cmd="./node_modules/prettier3/bin/prettier.cjs --plugin ./dist/index.js --parser=liquid-html --ignore-path=.prettierignore"
15+
else
16+
prettier='./prettier2'
17+
cmd="./node_modules/prettier2/bin-prettier.js --plugin . --parser=liquid-html"
18+
fi
19+
20+
# format with prettier2
21+
ln -s $prettier node_modules/prettier
22+
23+
# cleanup when done
24+
trap cleanup EXIT
25+
26+
# run command for version
27+
run $cmd "$@"

0 commit comments

Comments
 (0)