diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3f46b6de..44612113 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,8 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + name: build on: [push, pull_request] +env: + # Don't install Git hooks. + HUSKY: 0 jobs: license-check: runs-on: ${{ matrix.os }} diff --git a/.husky/install.js b/.husky/install.js new file mode 100644 index 00000000..3e34ed4b --- /dev/null +++ b/.husky/install.js @@ -0,0 +1,26 @@ +/* + Copyright 2024 the JSDoc Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Skip Husky install in production and CI. + +let husky; + +if (process.env.NODE_ENV === 'production' || process.env.CI === 'true') { + process.exit(0); +} + +husky = (await import('husky')).default; +console.log(husky()); diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..35593d03 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npm run default diff --git a/.license-check.json b/.license-check.json index 0c8dcff2..462938a9 100644 --- a/.license-check.json +++ b/.license-check.json @@ -4,6 +4,8 @@ "append": "" }, "ignore": [ + ".husky/_/**/*", + ".husky/pre-commit", ".parcel-cache", "**/.*", "!**/.*.js", diff --git a/package-lock.json b/package-lock.json index 658cc05e..7ef85cad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,6 +42,7 @@ "eslint": "^8.57.0", "execa": "^8.0.1", "hereby": "^1.8.9", + "husky": "^9.0.11", "jasmine": "^5.1.0", "jasmine-console-reporter": "^3.1.0", "js-green-licenses": "^4.0.0", @@ -5216,6 +5217,21 @@ "ms": "^2.0.0" } }, + "node_modules/husky": { + "version": "9.0.11", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz", + "integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==", + "dev": true, + "bin": { + "husky": "bin.mjs" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", diff --git a/package.json b/package.json index 715d7716..8deab435 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "eslint": "^8.57.0", "execa": "^8.0.1", "hereby": "^1.8.9", + "husky": "^9.0.11", "jasmine": "^5.1.0", "jasmine-console-reporter": "^3.1.0", "js-green-licenses": "^4.0.0", @@ -43,6 +44,7 @@ "license-check": "node_modules/.bin/hereby license-check", "license-headers": "node_modules/.bin/hereby license-headers", "lint": "node_modules/.bin/hereby lint", + "prepare": "node .husky/install.js", "test": "node_modules/.bin/hereby test" }, "workspaces": [