Skip to content

Commit

Permalink
ci(commit): run tests on commit, verify commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BerkeleyTrue committed Aug 13, 2021
1 parent 7112b5b commit 00ddb6e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test -- --no-watch
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
"scripts": {
"lint": "eslint --ext=js,jsx .",
"lint:fix": "eslint . --ext=js,jsx --fix",
"xpretest": "npm run lint",
"pretest": "npm run lint",
"test": "node scripts/test",
"cover": "npm run test -- --coverage",
"cover:watch": "browser-sync start --ss coverage --port 3001 -f coverage/index.html & nodemon --watch src/**/* --watch test/**/* --delay 2 --exec 'npm run test && npm run cover'",
"cover:open": "open coverage/index.html",
"format": "prettier '*.js' 'src/**/*' 'test/**/*' --write",
"postformat": "npm run lint:fix",
"commit": "git-cz",
"commitmsg": "commitlint -e $GIT_PARAMS",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"prepare": "husky install"
},
"config": {
"commitizen": {
Expand Down Expand Up @@ -50,7 +49,7 @@
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.4.0",
"husky": "^7.0.1",
"husky": "^7.0.0",
"jest": "^27.0.6",
"jest-circus": "^27.0.6",
"jest-pnp-resolver": "^1.2.2",
Expand Down
3 changes: 2 additions & 1 deletion scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ if (
// not ci
!process.env.CI &&
// and not coverage
!argv.includes('--coverage')
!argv.includes('--coverage') &&
!argv.includes('--no-watch')
) {
// https://github.com/facebook/create-react-app/issues/5210
const hasSourceControl = isInGitRepository() || isInMercurialRepository();
Expand Down

0 comments on commit 00ddb6e

Please sign in to comment.