From 06b835658835eca6069f0e0e72a7174e9ed6b346 Mon Sep 17 00:00:00 2001 From: Div Arora Date: Fri, 3 Dec 2021 13:47:47 +0530 Subject: [PATCH] Run package-local prettier Instead of running a single global version of prettier, which might conflict with the package-local version that editors might be using, we instead run prettier within each package that has it installed as a dependency. --- .github/workflows/prettier.yml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 52368d51dea..ff15da37790 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -13,6 +13,24 @@ jobs: uses: actions/checkout@v2 - name: Run prettier run: |- - npx prettier -c 'examples/**/*.{js,jsx,ts,tsx,css,md,json}' + function run_check() { + if $(grep -q '"prettier"' "$1") ; then + pushd "$(dirname $1)" + echo "Running prettier on $(pwd)" + npx prettier -c '**/*.{js,jsx,ts,tsx,css,md,json}' + popd + fi + } + find . -type f -name 'package.json' ! -path '*node_modules*' -print0 | while IFS= read -r -d '' file; do + run_check "$file" + done + + # i18n is not a node package, so we handle that one separately + format-i18n: + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v2 + - name: Run prettier + run: |- npx prettier -c 'i18n/**/*.{js,jsx,ts,tsx,css,md,json}' - npx prettier -c 'www/**/*.{js,jsx,ts,tsx,css,md,json}'