vendredi 17 janvier 2020

Angular 8 Husky, Pre Commit Condition on Code Coverage

I have an angular 8 project and I am trying to set up a case where the user cannot commit unless certain % of code coverage passes.

I am using NX Workspace, and Husky to run Linting before committing. I want to run on top of this, ng test, and also % of coverage test for which I can provide the number. If all three pass, then commit the code.

I have this package.json file for now. How can I add on top of this?

  "scripts": {
    "ng": "ng",
    "nx": "nx",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "nx workspace-lint && ng lint",
    "e2e": "ng e2e",
    "affected:apps": "nx affected:apps",
    "affected:libs": "nx affected:libs",
    "affected:build": "nx affected:build",
    "affected:e2e": "nx affected:e2e",
    "affected:test": "nx affected:test",
    "affected:lint": "nx affected:lint",
    "affected:dep-graph": "nx affected:dep-graph",
    "affected": "nx affected",
    "format": "nx format:write",
    "format:write": "nx format:write",
    "format:check": "nx format:check",
    "update": "ng update @nrwl/workspace",
    "update:check": "ng update",
    "workspace-schematic": "nx workspace-schematic",
    "dep-graph": "nx dep-graph",
    "help": "nx help",
    "storybook": "start-storybook -p 6006",
    "build-storybook": "build-storybook"
  },
  "husky": {
    "hooks": {
      "pre-commit": "npm run affected:lint"
    }
  },

...

Aucun commentaire:

Enregistrer un commentaire