Skip to content

Commit

Permalink
chore: add pre-commit hook to run linter and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hegemonic committed Apr 19, 2024
1 parent 3011f86 commit a08ac18
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
26 changes: 26 additions & 0 deletions .husky/install.js
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run default
2 changes: 2 additions & 0 deletions .license-check.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"append": ""
},
"ignore": [
".husky/_/**/*",
".husky/pre-commit",
".parcel-cache",
"**/.*",
"!**/.*.js",
Expand Down
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": [
Expand Down

0 comments on commit a08ac18

Please sign in to comment.