From c0e211f6f4ba6a75696e5c1739b67447cf8f48c4 Mon Sep 17 00:00:00 2001 From: Lam Wei Li Date: Wed, 28 Sep 2022 14:08:53 +0800 Subject: [PATCH 1/2] ci: manually downgrade dev dependencies for older versions --- .github/workflows/node.js.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 3e39a82..5a867d4 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -26,13 +26,16 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ include: - node-version: 8.x - npm-i: "@commitlint/cli@9.x @commitlint/config-conventional@9.x eslint@6.x eslint-config-airbnb-base@14.x eslint-config-prettier@6.x fs-extra@8.x husky@6.x" + npm-i: "eslint@6.x eslint-config-airbnb-base@14.x eslint-config-prettier@6.x eslint-plugin-prettier@3.x fs-extra@8.x nyc@14.x tap@14.x" - node-version: 10.x - npm-i: "@commitlint/cli@12.x @commitlint/config-conventional@12.x eslint@7.x fs-extra@9.x husky@6.x" + npm-i: "eslint@7.x fs-extra@9.x nyc@14.x tap@14.x" - node-version: 12.x - npm-i: "@commitlint/cli@16.x @commitlint/config-conventional@16.x husky@7.x" + npm-i: "nyc@14.x tap@14.x" + + - node-version: 14.x + npm-i: "nyc@14.x tap@14.x" steps: - uses: actions/checkout@v3 From 2591afb379380676696a4b2893ff0859be162714 Mon Sep 17 00:00:00 2001 From: Lam Wei Li Date: Wed, 28 Sep 2022 17:04:29 +0800 Subject: [PATCH 2/2] ci: skip prettier on older Node.js (8.x, 10.x, 12.x) --- .github/workflows/node.js.yml | 7 +++++++ package.json | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 5a867d4..488e2cb 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -60,6 +60,13 @@ jobs: echo "::set-output name=install::npm ci" fi + - name: Disable prettier on older Node.js (8.x, 10.x, 12.x) + run: | + sed -i '/"prettier": "prettier/d' package.json + echo Removed + sed -n '/"prettier": "prettier/p' package.json + if: contains(fromJson('["8.x", "10.x", "12.x"]'), matrix.node-version) + - name: Install downgraded modules ${{ matrix.npm-i }} run: | npm install --save-dev ${{ matrix.npm-i }} diff --git a/package.json b/package.json index e37de15..dd3610e 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,8 @@ }, "scripts": { "prepare": "is-ci || husky install", - "pretest": "prettier --check \"**/*.*\" && eslint \"lib/**/*.js\" \"test/**/*.js\"", + "pretest": "npm run prettier --if-present && eslint \"lib/**/*.js\" \"test/**/*.js\"", + "prettier": "prettier --check \"**/*.*\"", "prettier:fix": "prettier --write \"**/*.*\"", "test": "tap \"test/tap/**/*.js\" --cov --reporter=classic --timeout=45", "typings": "tsc -p types/tsconfig.json"