chore: add pre-commit hook to run linter and tests

This commit is contained in:
Jeff Williams 2024-04-18 19:21:52 -07:00
parent 3011f86eda
commit a08ac18a11
No known key found for this signature in database
6 changed files with 51 additions and 0 deletions

View File

@ -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 }}

26
.husky/install.js Normal file
View File

@ -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());

1
.husky/pre-commit Normal file
View File

@ -0,0 +1 @@
npm run default

View File

@ -4,6 +4,8 @@
"append": ""
},
"ignore": [
".husky/_/**/*",
".husky/pre-commit",
".parcel-cache",
"**/.*",
"!**/.*.js",

16
package-lock.json generated
View File

@ -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",

View File

@ -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": [