Skip to content

Commit

Permalink
feat(circular deps): add pre-push commit hook to check for circular deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Schneider committed Sep 30, 2021
1 parent 5ac767a commit 9632b0d
Show file tree
Hide file tree
Showing 3 changed files with 431 additions and 10 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged && node ./scripts/commitHook.js"
"pre-commit": "lint-staged && node ./scripts/commitHook.js",
"pre-push": "node ./scripts/checkForCircularDeps.js"
}
},
"lint-staged": {
Expand Down Expand Up @@ -184,6 +185,7 @@
"jest-css-modules": "2.1.0",
"jest-fetch-mock": "3.0.3",
"lint-staged": "10.5.4",
"madge": "5.0.1",
"mock-socket": "9.0.3",
"node-polyfill-webpack-plugin": "1.1.4",
"prettier": "2.3.2",
Expand Down
14 changes: 14 additions & 0 deletions scripts/checkForCircularDeps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable */
const chalk = require('chalk')
const madge = require('madge')

madge('./packages/blockchain-wallet-v4-frontend/src/index.js').then((res) => {
const result = res.circular()
if (result && result.length > 0) {
console.log(chalk.red.bold(`Error: ${result.length} circular dependencies found`))
result.forEach((r) => {
console.log(chalk.yellow(JSON.stringify(r)))
})
process.exit(1)
}
})
Loading

0 comments on commit 9632b0d

Please sign in to comment.