Skip to content

Commit

Permalink
chore: add husky and hook build/format/lint checks to pre-commit
Browse files Browse the repository at this point in the history
This enforces the same checks locally that will execute in CI

With this, everyone should have a clean / consistent dev environment,
and it will be clear to contributors if they submit code that is not valid
typescript

Additionally, after doing the build it adds the dist/index.js output to the
commit list so contributors can't forget to commit it
  • Loading branch information
mikehardy committed Apr 11, 2021
1 parent 55cf49e commit accbea4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions .husky/.gitignore
@@ -0,0 +1 @@
_
3 changes: 3 additions & 0 deletions .husky/pre-commit
@@ -0,0 +1,3 @@
#!/bin/sh
yarn build && git add dist/index.js
yarn format-check
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"build": "ncc build src/index.ts --license LICENSES.txt",
"format": "prettier --write '**/*.ts'",
"format-check": "prettier --check '**/*.ts'"
"format-check": "prettier --check '**/*.ts'",
"prepare": "husky install"
},
"dependencies": {
"@actions/core": "1.2.6",
Expand All @@ -15,6 +16,7 @@
"devDependencies": {
"@vercel/ncc": "0.27.0",
"prettier": "2.2.1",
"typescript": "4.1.5"
"typescript": "4.1.5",
"husky": "6.0.0"
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -126,6 +126,11 @@ deprecation@^2.0.0, deprecation@^2.3.1:
resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919"
integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==

husky@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/husky/-/husky-6.0.0.tgz#810f11869adf51604c32ea577edbc377d7f9319e"
integrity sha512-SQS2gDTB7tBN486QSoKPKQItZw97BMOd+Kdb6ghfpBc0yXyzrddI0oDV5MkDAbuB4X2mO3/nj60TRMcYxwzZeQ==

is-plain-object@^4.0.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-4.1.1.tgz#1a14d6452cbd50790edc7fdaa0aed5a40a35ebb5"
Expand Down

0 comments on commit accbea4

Please sign in to comment.