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

Commit

Permalink
Add prettier2/prettier3 scripts for sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
charlespwd committed Jul 12, 2023
1 parent c408323 commit e9584a9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
"playground": "npx http-server playground",
"prepare": "husky install",
"prerelease": "scripts/prerelease",
"prettier": "prettier --plugin . --parser=liquid-html",
"prettier": "scripts/prettier",
"prettier2": "cross-env PRETTIER_MAJOR=2 scripts/prettier",
"prettier3": "cross-env PRETTIER_MAJOR=3 scripts/prettier",
"test": "node_modules/.bin/mocha '{src,test}/**/*.spec.ts'",
"test:3": "cross-env PRETTIER_MAJOR=3 yarn test",
"test:idempotence": "cross-env TEST_IDEMPOTENCE=true node_modules/.bin/mocha 'test/**/*.spec.ts'",
Expand Down
27 changes: 27 additions & 0 deletions scripts/prettier
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

cleanup() {
rm node_modules/prettier
}

run() {
echo "$@"
$@
}

if [[ $PRETTIER_MAJOR = 3 ]]; then
prettier='./prettier3'
cmd="./node_modules/prettier3/bin/prettier.cjs --plugin ./dist/index.js --parser=liquid-html --ignore-path=.prettierignore"
else
prettier='./prettier2'
cmd="./node_modules/prettier2/bin-prettier.js --plugin . --parser=liquid-html"
fi

# format with prettier2
ln -s $prettier node_modules/prettier

# cleanup when done
trap cleanup EXIT

# run command for version
run $cmd "$@"

0 comments on commit e9584a9

Please sign in to comment.