Skip to content

Commit a08ac18

Browse files
committed
chore: add pre-commit hook to run linter and tests
1 parent 3011f86 commit a08ac18

File tree

6 files changed

+51
-0
lines changed

6 files changed

+51
-0
lines changed

.github/workflows/ci.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
1415
name: build
1516
on: [push, pull_request]
17+
env:
18+
# Don't install Git hooks.
19+
HUSKY: 0
1620
jobs:
1721
license-check:
1822
runs-on: ${{ matrix.os }}

.husky/install.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Copyright 2024 the JSDoc Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Skip Husky install in production and CI.
18+
19+
let husky;
20+
21+
if (process.env.NODE_ENV === 'production' || process.env.CI === 'true') {
22+
process.exit(0);
23+
}
24+
25+
husky = (await import('husky')).default;
26+
console.log(husky());

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run default

.license-check.json

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"append": ""
55
},
66
"ignore": [
7+
".husky/_/**/*",
8+
".husky/pre-commit",
79
".parcel-cache",
810
"**/.*",
911
"!**/.*.js",

package-lock.json

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"eslint": "^8.57.0",
2222
"execa": "^8.0.1",
2323
"hereby": "^1.8.9",
24+
"husky": "^9.0.11",
2425
"jasmine": "^5.1.0",
2526
"jasmine-console-reporter": "^3.1.0",
2627
"js-green-licenses": "^4.0.0",
@@ -43,6 +44,7 @@
4344
"license-check": "node_modules/.bin/hereby license-check",
4445
"license-headers": "node_modules/.bin/hereby license-headers",
4546
"lint": "node_modules/.bin/hereby lint",
47+
"prepare": "node .husky/install.js",
4648
"test": "node_modules/.bin/hereby test"
4749
},
4850
"workspaces": [

0 commit comments

Comments
 (0)